@anmonteiro Your project reminds me of the lisp based DSSSL https://eager.io/blog/the-languages-which-almost-were-css/#the-turing-complete-stylesheet
@stephenway wasn’t aware of that
It never became a standard language, but has some awesome ideas around it!
like inherited values
that project uses garden to generate the styles
the rationale behind it is that if we’re colocating queries, why not styles too 🙂
yea, makes sense
are media queries handled in an external stylesheet?
didn’t think about that (yet)
can’t we do it in garden?
I’ve never tried garden
I believe there is going to be a new alpha release of Garden with a bunch of changes in the next few weeks - might be some useful ideas to look at there as well
@shaun-mahood Do you know where I can find that? Can’t find a branch or tag on github.
Not out yet, you could check with @noprompt when he is planning a release
ahh ok, I was just curious if that release would have collocated styles
@anmonteiro I'm noticing a trend of people overriding defui
. It occurs to me that this approach does not compose. The next challenge, perhaps?
@tony.kay yes! That’s one thing I regret
we're wanting to instrument it to add in debugging capabilities in the browser during dev, and lots of libs seem to want to do things like your css lib
one of the hard requirements of that project though is that we generate a CSS file in the end
this has to be done on the JVM side, of course
I understand. Same problem for the debugging tools. The hack has to take place at the react level
well the thing is it needs to be a macro
Do you leverage the real defui
inside of your macro?
it probably doesn’t need to be colocated in the sense that it’s a protocol to implement in defui
maybe some other macro like defcss
that can be colocated above the defui
macro, like core.typed
annotations are
I have to think about that. feel free to open issues if you wanna discuss that
sure, ok
in the meantime I'm going to play with it for sure
👍
@anmonteiro my expectation is to have an alpha available in the next couple of weeks. the next version of garden is addressing specific pain points of issues that are difficult to close with the current implementation. the most significant improvements will be support for parsing/manipulating "raw" CSS and a dramatically cleaner, clearer, and more extensible compiler.
@anmonteiro how about, instead of a defui override, a function that can be called in the body of render? E.g. (render [this] (apply-css (dom/div #js {:class :root} ...)))
I guess that adds some runtime overhead
@tony.kay where would you define the actual styles?
same way you were...oh, I missed passing this
as a parameter
Actually, if you passed the class name as a parameter, it could probably be a macro
ultimately, for render you just need to know the name munging, right?
Also, does :class
accept a seq as well? Might want multiple classes on an element
yep
yep 2x?
"<= use a vector [:one :two]
to add multiple classes to an element"
ah, missed that
and yeah, for render I just need to know the munging
so that would eliminate the need for an override of defui
what I meant earlier by the defcss
was that it could take the class
somewhat akin to clojure.spec/fdef
Yeah, and then that would be reusable
but we’d lose colocation actually inside defui
which might actually not be that important
you could still just use a static protocol, but yeah, probably less important
couldn’t use a static protocol without overriding the defui macro
why?
because I do static analysis on the defined styles
and evaluate them on the Clojure side
to generate the CSS file
which is also the reason why variables must be defined in a .cljc
file
https://github.com/ladderlife/om-css#user-defined-variables-in-colocated-styles
oh right, you'd have to be running cljs to do it otherwise
node integration? 😄
btw, the current CSS spitting works great with e.g. Figwheel development
we’d lose that if Node
🙂
ah yes
that is a really nice feature
Yeah, I'm liking the defcss idea. avoids the defui composition problem, but gets all of the good results.
yep
Is this being used at LFin?
not currently I think
I just saw the ©️
hard to change a lib that much once adopted
it was but they’ve replaced it with something very similar
so definitely up for the churn
😛
problem with defcss
is then we’d need to wrap the render function too
that can be a pro as well, though, because it opens the door to further composition and reuse
which you mentioned above with apply-css
(apply-css [Style1 Style2] ...)
hrm
Oh we’re thinking different things
and your idea is probably better
I was thinking:
(defcss Foo ..)
(defui Foo ..)
I see, yeah I was thinking more general
and the Foo styles would only be applied to Foo
probably harder to do your idea because of prefixing
actually maybe not
not really, only conflict resolution
if you use the same name twice, it would be ambiguous in the component
yeah
but that's easy enough to throw a warning on and resolve by hand