-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Improve the gathering of the CSS classes in the source code #28
Comments
I am not sure of which approach to use here. Any suggestion or help is welcome. Here are my most important goals:
Nice to have:
|
Maybe the best API is "no API". One solution which I imagine is just asking the user to annotate the CSS classes using metadata and do a static analysis on the source code to find them.
;; Using ^:css
(defn todo-list-comp [todo-list]
[:div {:class ^:css ["ml-2" "py-2"])}
(for [todo-item (:todo-items todo-list)]
[todo-item-comp todo-item "not-a-class" ^:css "this-is-a-class"])])
;; This would work too
(defn todo-list-comp [todo-list]
[:div {:class ^:css (conj ["ml-2"] :py-2)}
(for [todo-item (:todo-items todo-list)]
[todo-item-comp todo-item "not-a-class" ^:css "this-is-a-class"])])
;; Using ^:hiccup
(defn todo-list-comp [todo-list]
^:hiccup
[:div.ml-2.py-2
(for [todo-item (:todo-items todo-list)]
[todo-item-comp todo-item "not-a-class" ^:css "this-is-a-class"])])
;; This would work too
(defn todo-list-comp [todo-list]
^:hiccup
[:div {:class ["ml-2" "py-2"]}
(for [todo-item (:todo-items todo-list)]
[todo-item-comp todo-item "not-a-class" ^:css "this-is-a-class"])]) |
After a fruitful discussion with @p-himik on Slack, I realized that:
Some things I will try during the holidays:
Any help, code contribution or advice is welcome. |
The library Today I found https://github.com/clj-kondo/clj-kondo/tree/master/analysis which might be useful to find all usages of the |
Currently, the tool only finds strings inside the shape |
This is what I have in mind:
I think that this pattern would compose better with any existing
defn-ish
way people use to define their Clojure root variables, and it has the merit do be explicit.The text was updated successfully, but these errors were encountered: