Hey guys, I just tried Garden… I am probably not the first one asking this: but can someone “sell" it to me? I do like hiccup syntax and we use it a lot for html, but using Garden feels kinda strange (compared to SASS for example). I dunno, maybe I just need to play with it a bit more. Still, even if I get used to use it and like it, I'm gonna need to sell it to my colleagues. How do I convince them?
@ag: Selling it to colleagues may be a bit harder than selling it to you, but I find that there are 2 huge benefits for me. 1) same hiccup syntax means no difficulty in jumping back and forth between clojure on the server, clojurescript in the browser (with reagent), and garden. 2) there are many more options in Garden than in CSS or SASS for dealing with variables, control flow, logic, and any other concerns that make more sense in a full programming language - I've found the ability to deal with variables and namespaces in Garden has had an amazingly simplifying effect on some of my stylesheets, even compared with Sass. Hope those are a bit of help, happy to clarify tomorrow if you want more specifics.
The biggest advantage of Garden in my opinion is that it sits inside of the Clojure language. So you no longer have to deal with limitations of a pre-processor. You can write functions that will generate styles on demand within React components as the user changes dials which is something much easier to accomplish with Garden compared to LESS or SASS.
garden.color is also magical and incredibly powerful.
another selling point is that you can share code between clj and cljs. i was recently integrating a JS lib (chartist) which uses media queries for some features. i was delighted when i realized i could literally use the same named breakpoints for chartist that i use to compile my CSS, with exactly the same semantics and no code duplication/maintenance headaches.
re: garden vs sass/less, when my team picked garden, i did an evaluation comparing feature sets. the only thing sass had that garden didn't was "extend-only selectors", which i implemented trivially (for trivial cases) in a few hours in clojure. my team now maintains a (less trivial) implementation (https://github.com/reup-distribution/espalier) which we use in production. implementing a feature like this for sass would require knowing the sass internals (ruby) and working with how it parses and compiles its own DSL... whereas garden operates on plain clojure datastructures
(for anyone reading source, clearly there is some knowledge of garden internals involved, because the full implementation essentially embeds a multi-pass compilation step into a single-pass compiler; but the fact that it's a real language rather than a DSL makes reasoning about the problem so much easier)
thank you guys for good write-up @niamu @shaun-mahood @eyelidlessness this is cool. Now, we have a sass-lib (build by our non-clojure team) and I’m gonna have to use mixins from that thing. Is there a way? If I find a way - I’ll just switch to Garden
I believe the next release of Garden will be able to read in existing CSS files as Garden data structures which would allow you to do that I assume. But as of right now nothing in Garden itself facilitates that.
😞 do you know when next release comes? I think I’m already liking the idea of having everything in symbolic expressions
@ag: How many mixins have you got, and how complicated are they? I've not done much with mixins (and I'm the only developer so I only have to convince myself), but it seems like it would be pretty easy to recreate and stay in sync with SASS if there weren't too much of it.
that’s the thing… I’m not in control of that lib. it’s built by another team, and I have no way of not using it (bureaucracy).
if I could build some sort of a bridge that would allow me to use those mixins… they have bunch of mixins. for example something like this: get-color(gray, darker)
and whenever "their definition” of darker gray changes it would change in my app too
Ahh, that makes it a bit trickier. Do you think you could write something in Clojure to read those mix-ins? If you can do it in Clojure then it should be easy to pass it into Garden.
It’s not exactly mature or well-documented right now, but you might want to toy around with this for an evening: https://github.com/noprompt/thorn
@niamu i wouldn't recommend using that at all.
what i might recommend is looking for a real sass parser written in java and write code against that.
thorn uses jruby and an older version of the sass gem. it's really hacky.