Fork me on GitHub
#hoplon
<
2016-11-23
>
onetom02:11:34

@laforge49 im using hoplon ui where i pretty much only need elem, but i still need some hoplon stuff regularly, so paste this to the top of my hoplon/ui .cljs files:

; Establish project-wide NS aliases and refer most common symbols
    [javelin.core :as j :refer [cell cell= defc defc= cell-let with-let]]
    [hoplon.core :as h :refer [defelem when-tpl if-tpl case-tpl for-tpl]]
    [hoplon.ui :as hui :refer [elem]]
    [hoplon.ui.attrs :refer [+ - * / c r pt em px d]]
    [material.ui :as mui :refer [container row paper]]

onetom02:11:40

i found it to be a good compromise

onetom02:11:03

(`:refer`ring macros like this needs cloujrescript 1.9.x though)

onetom02:11:58

you can find more details about how to make cursive's lein support friends with boot here: https://github.com/cursive-ide/cursive/issues/692#issuecomment-257907140

laforge4902:11:37

@onetom Useful. Thanks!

peterromfeld07:11:40

someone has an example for fileupload from hoplon->castra?

onetom14:11:42

@peterromfeld you mean just upload to the backend, not to S3 directly?

onetom14:11:22

i have some hoplon+castra+s3 upload, but A. it's not isolated yet into a library B. it doesn't work with temporary credentials acquired from the instance metadata service, just with static ones BUT here is some code which can give you some ideas: 1. https://github.com/hoplon/ui/blob/master/src/hoplon/ui.cljs#L387-L401 2. https://github.com/martinklepsch/s3-beam 3. AWS v4 signature support for s3-beam: https://github.com/martinklepsch/s3-beam/pull/36

grant15:11:28

Am I correct in my understanding that hoplon/ui will be replacing hlisp as the recommended way to build views in the future?

mynomoto15:11:23

@grant I don't think that is the case, hoplon/ui is an alternative. You can always use hlisp by itself.

mynomoto15:11:57

Actually as the recommended way I think it may 😉

micha15:11:58

yeah the two need to be separate, it's good to have a layered architecture

grant15:11:36

So are they two layers in the same cake? They seemed to have overlapping concerns. But that could be my misunderstanding, I'm just starting to look at them.

grant15:11:49

I was not thinking that hlisp would go away or be deprecated, just that you'd generally use one or the other, not both.

micha15:11:25

yes this is the dream

micha15:11:47

the dream is to have a higher-level thing to actually write applications in

flyboarder18:11:24

@micha @alandipert I am doing a Hoplon talk for ClojureRemote this year, would either of you guys be interested in that?

alandipert18:11:31

i will definitely watch it if that's what you mean!

flyboarder18:11:59

@alandipert: cool, but I'm actually wondering if either of you or anyone else would like to be involved 😜

laforge4918:11:52

I have an element which has various elements toggle on or off based on my reroute cell. I have another element whose size will depend on the size of that first element. Not wanting to get into a race condition, is there something I can watch which tells me when an element has changed?

alandipert18:11:00

at the very least i'm happy to be a prototype audience and give you notes

alandipert18:11:24

also down to be involved somehow, would be flattered. altho i'm weary of A/V mechanics for multiple presenters

laforge4918:11:14

(my js is ultra weak, which I suspect is the problem here.)

laforge4919:11:04

Ah. onchange I suspect will do it.

laforge4921:11:05

I've tried a number of events to no effect.

laforge4921:11:03

Isn't there some event that is triggered when an element is toggled?

laforge4921:11:21

Perhaps there is some way of seeing which events are triggered?

laforge4921:11:45

Perhaps I just need a watch on reroute. That might be simpler.

micha21:11:06

@laforge49 usually you want to just hook up whatever causes the toggling to a cell

micha21:11:37

rather than trying to have the element tell you when something was done to it

micha21:11:36

@flyboarder sorry I'm on the road but that sounds great, let me know if there is anything i can help with

laforge4921:11:27

yup and the add-watch does that. But the problem is a race condition. I want to get the size of the displayed element. Size is only valid I think when the element is visible. so I want to look at the size AFTER the element is displayed. Of course, I am not sure this is a problem. Verifying the issue is my next step I guess.

laforge4921:11:36

I'll be using getBoundingClientRect to get the size.

laforge4921:11:47

So my hope @micha is to update the height of the element after a subelement has become visible.

laforge4921:11:50

I have a header element displayed at the top of the page. Its height varies. And I need to know when the height changes so I can change the size of the elements under it.

laforge4921:11:13

What confuses me is having hoplon sitting between my code and the jquery toggle. I suspect there is no way to get hoplon to do a callback when a toggle competes.

flyboarder21:11:35

@laforge49: that's what javelin cells are for you can have custom attributes that fire when the cell changes

laforge4922:11:35

So after the cell changes, do I put in a delay before I grab the element's new height? I don't want to grab the height when the cell changes, but AFTER the effect of the toggle that is triggered by a change to the cell.

laforge4922:11:34

Or are you saying that I can change the value of a cell as an effect of the completion of a toggle???

laforge4922:11:53

Easiest would be if there were some js event that was triggered when the height of an element changes. But I can't figure that one out.

laforge4922:11:31

--my js is weak

laforge4922:11:46

I've found ontoggle. But it doesn't seem to work for me. Some bug?

flyboarder22:11:25

You can attach a cell to an object property and watch it change look for prop-cell @laforge49

laforge4922:11:25

OK. So is their a property on a dom element which changes when the element is toggled?

flyboarder22:11:48

I would just make a simple cell and toggle it then have another one what watches for the that state

flyboarder22:11:36

You can independently toggle the cell and watch for the change with another formula

laforge4922:11:54

I'm toggling dom elements.

laforge4922:11:35

So the css display property is apparently updated when a dom element is toggeled by jquery.

laforge4922:11:12

And I can attach a cell to a property. Now I just need to know how to access the css display property of a dom element.

laforge4922:11:59

document.getElementById("myDIV").style.display = "none";

flyboarder22:11:15

That state should be stored in a cell somewhere and then toggle the element based on that cell

laforge4922:11:59

Yeah, I have no problem toggling an element. I just want a cell that synch with the display property. So thanks @flyboarder for pointing out prop-cell. 🙂

flyboarder22:11:06

So usually you would store that in a cell and just reference it within the CSS attribute

flyboarder22:11:33

Like (def my-state nil) (my-elem :toggle my-state :css (cell= {:some-class my-state}))

flyboarder22:11:05

Or something like that @laforge49

laforge4922:11:17

You seem to be fixated on the toggling of an element, whereas my concern is getting the height of an element AFTER it has been toggled, not while it is being toggled.

laforge4922:11:10

But I think I have enough pieces now to do that.

flyboarder22:11:46

Ah i see, yeah then the property cell is what you want I think @laforge49 sorry I thought you wanted the toggle state

laforge4923:11:22

Is ok @flyboarder. Again, thanks bunches!