garden
garden copied to clipboard
Classnames derived from fully qualified namespaces
trafficstars
By using fully qualified namespaces in classnames, we can pretty much get rid of name-collisions. What if garden would do something like this:
(ns foo
(:require [garden.core :refer [css]]))
(css [[::.bar {:display :block}]
[::#baz {:display :none}]])
;; => ".foo-bar { display: block; } #foo-baz { display: none; }"
Instead of the current:
;; => "foo|.bar { display: block; } foo|#bar { display: none; }"
We would only need a tiny fn that we use in our hiccup to create such classnames from keywords. Usage could be something like:
[:a {:class (classnames ::bar (when active? :active))} "Bar"]
Is it a good idea?
@hkjels I see where you are coming from. When I originally took on the task of parsing namespaced keywords to something CSS friendly, I used the existing namespace concept from CSS which is why it parses and thus compiles the way it does. I think what we need here is a way to customize that part of the parsing step so you can get the control you want.