This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-12
Channels
- # announcements (1)
- # babashka (42)
- # beginners (114)
- # bristol-clojurians (2)
- # calva (7)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (37)
- # cljsrn (13)
- # clojure (114)
- # clojure-austin (3)
- # clojure-europe (5)
- # clojure-nl (10)
- # clojure-spec (77)
- # clojure-sweden (4)
- # clojure-uk (16)
- # clojurescript (52)
- # conjure (155)
- # core-async (18)
- # cursive (23)
- # datomic (20)
- # duct (2)
- # emacs (13)
- # figwheel (3)
- # figwheel-main (9)
- # fulcro (31)
- # gis (8)
- # helix (33)
- # jobs (12)
- # jobs-discuss (66)
- # kaocha (4)
- # lein-figwheel (1)
- # meander (16)
- # off-topic (5)
- # pathom (13)
- # pedestal (6)
- # quil (6)
- # rdf (17)
- # re-frame (32)
- # reagent (34)
- # reitit (30)
- # remote-jobs (1)
- # ring (2)
- # shadow-cljs (149)
- # spacemacs (1)
- # sql (8)
- # tools-deps (90)
- # xtdb (19)
I think I let this get lost in history, what's the thoughts on $
supporting class names in the type string? e.g. ($ "div.foo.bar.baz-bosh")
@lilactown (d/div {:class "foo bar baz-bosh"})
vs ($ "div.foo.bar.baz-bosh")
- really just for reducing typing I guess.
at least for the simple case of no properties. I'm very greenfield, so I do a lot of translating html into react.
IME building an app, you typically end up needing something to compose class names together
in order to get sane precedence rules, you need to use emotion/cx
to combine classes which means you can’t use the shorthand
I distinctly don't want to use css-in-js 😁. Not sure what cx does, but would [class1 class2 class3]
have worked there too?
it would not work the same; the CSS-in-JS solution would do a merge of those styles, using the order I wrote them as precedence
writing them as [class1 class2 class3]
would use CSS precedence which means whatever order they were defined in
I think manual is fine for that case. This is really to optimize for "doing normal css stuff".
my suggestion would be to create a macro that wraps $
:
(defmacro $
[type maybe-props & args]
(let [[type' class-string] (process-class type)
maybe-props' (add-class maybe-props class-string)]
`(helix/$ ~type' ~maybe-props' ~@args)))
and if you find this works really well, I would think about taking a PR for itthis isn’t the first time someone has asked about this so, I’m willing to accept it might just be a use case I don’t have - doesn’t make it invalid 😛
Sounds like a plan. Is add-class gonna be a pain to write with all the js object possibilities?