As I said I haven't used garden, can't say how much of a difference there is. 
One thing I can't change is that selectors have to be strings, they are 
keywords in garden. The maps of css properties should be portable though and 
you shouldn't really need the selectors after?

As for re-using css classes: Don't! That is the whole point of this, as 
mentioned here: http://mrmrs.io/writing/2016/03/24/scalable-css/ and elsewhere.

I have been in this situation many times where I'm scared to touch an existing 
class since I have no direct record of who uses it in which situation. Or where 
I added another class with !important, just to have a quick fix somewhere. Also 
I hated OOCSS with things like <div class="foo bar baz boom bang fiddle"> where 
the actual order mattered and I never could remember which it was.

You can and should however abuse all the power of Clojure. I have this for some 
of my styles:

(defn button-style [env]
  {:padding 10
   :border (str "1px solid " (-> env :colors :border))
   :background-color (-> env :colors :bg)})
   
and then re-use this a couple time for anything that should look like a button:

(defstyled link :a
  [env]
  (merge
    (button-style env)
    {:display "inline-block"
     :text-decoration "none"}))

(defstyled button :button
  [env]
  (merge
    (button-style env)
    {:you-get "the-idea"}))

I currently still have a base.css which includes normalizr.css and some other 
generic classes, you can of course still use (button {:className "generic"} 
...). Nothing wrong with that.


As for performance: The generated selectors are very specific in that they only 
match one thing, too open generic styles tend to cause issues. Also if you 
stick to "modern" things (flexbox) the need for some filler HTML elements goes 
away which improves overall performance, not just CSS. Style generation also 
happens ONCE, so even complex style-fns should not be an issue ever.

Also thanks for :advanced optimizations the code to generate the CSS should by 
much smaller than any actual minified CSS. Did I mention dead code removal yet? 
;)

But I currently have only 89 "defstyled" things in my project myself, as this 
is still fairly new. Too early to make general claims about performance, but it 
should probably be on par with hand-written CSS. Generating styles on the 
client might be a bad idea too, my stuff is not yet complex enough to say. Time 
will tell, I am committed however as the past few weeks produced basically zero 
headaches about CSS and that is a nice feeling.

/thomas


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to