Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classnames derived from fully qualified namespaces #154

Open
hkjels opened this issue Jan 3, 2018 · 1 comment
Open

Classnames derived from fully qualified namespaces #154

hkjels opened this issue Jan 3, 2018 · 1 comment

Comments

@hkjels
Copy link

hkjels commented Jan 3, 2018

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?

@noprompt
Copy link
Owner

noprompt commented Jan 4, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants