Fork me on GitHub
#reagent
<
2017-05-08
>
minikomi06:05:12

hmm any good util for building element class names based on predicates?

pesterhazy07:05:11

What do you mean @minikomi

minikomi07:05:26

ah, I had a bunch of values which, if not nil, I wanted certain classes appended to the main wrapper to control css/appearance ended up writing a macro, because some of the class names depended on the values being derefed (eg (name @background-type) ) takes pairs of [predicate classname], builds a space separated string

pesterhazy08:05:53

I think you can apply a vector as :class, but would have to verify

minikomi08:05:36

oh really? then i could just do like (and @value (str "something-" (name @value))) since and short circuits..

gadfly36108:05:21

You could use clojure.string/join and filter for nil? befote hand. Also the cond-> threading macro may be fun

pesterhazy08:05:31

For extra brevity use some->>

minikomi08:05:50

yeah i had that style originally, but thought there might be a more compact way to do it

minikomi08:05:17

hmm .. seems a vector joins the words by ,.. it does filter nil though.

pesterhazy08:05:24

Would be a nice enhancement though, maybe

gadfly36108:05:46

Is an example of the cond-> option

gadfly36108:05:17

I personally filter for nil? And then do a string/join

minikomi08:05:49

ooh cond-> looks pretty close to what i wanted, thanks