garden icon indicating copy to clipboard operation
garden copied to clipboard

Classnames derived from fully qualified namespaces

Open hkjels opened this issue 6 years ago • 1 comments

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 avatar Jan 03 '18 13:01 hkjels

@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.

noprompt avatar Jan 04 '18 21:01 noprompt