-
Notifications
You must be signed in to change notification settings - Fork 415
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-like dynamic css classes handling #305
Comments
I like this. We could even add this to reagent proper so that this works:
If the |
Relates to #154. |
And #138 I guess |
Something alone these lines or #154 would be really nice. II was also thinking it could be cool to be able to do something like:
which would then evaluate the boolean predicates and generate |
Reagent now supports collections of strings for |
But still no maps support, right? |
No. I'm a bit conflicted about adding support for maps. Implementation wise it would be really simple thing. API wise it would add another way to do the same thing. How much benefit would this have? Is is enough to outweigh the additional complexity of API. Think about how would you explain this thing to a new Reagent user:
[:div.always
{:class [:always2
(if (is-thing?) :some-class)
(if (is-another-thing?) :other-class)]}]
[:div.always
{:class
{:always2
:some-class (is-thing?)
:other-class (is-another-thing?)}}] Using vector is 5 characters more per class (two parenthesis and |
I agree. At the point where it is not
I have no intention of pushing maps support anymore. |
In react world, classnames is a standard library for handing dynamic css classes.
I didn't find the alternative solution, and I didn't want to use special object syntax to interop with
classnames
, so I've created class-names-cljs to perform this task.I thought it might be cool to try to bring such functionality to reagent so people coming from react can use familiar tools, also it seems more robust than just using inline
(str ...)
+if
s.The text was updated successfully, but these errors were encountered: