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

Support for class names as keywords #44

Closed
paintparty opened this issue May 25, 2020 · 5 comments
Closed

Support for class names as keywords #44

paintparty opened this issue May 25, 2020 · 5 comments

Comments

@paintparty
Copy link

Thanks for making Stylefy!
Really great project.

In order to maintain feature parity with reagent, would it be possible to support the following syntax in the second (html attributes) argument to use-style?

(use-style
    {:color "red"}               
    {:class :some-class})

And also a vector of keywords:

(use-style
    {:color "red"}               
    {:class [:some-class :some-other-class]})
@Jarzka
Copy link
Owner

Jarzka commented May 26, 2020

Glad you find stylefy useful.

I gave an answer to this, but I had to re-check it and it was partially incorrect, so I deleted it. Here is the new answer:

Yes, if this syntax works in Hiccup & Reagent, it should work in stylefy when you call use-style. Now it does not, and here is why:

Originally, the second param of use-style, meaning the option map, only accepted a map with a special keyword of ::with-classes. Later, I changed the implementation of the second param so that the whole map contains HTML attributes. However, since some people had already used ::with-classes, I had to implement support for it. Thus, how stylefy handles :class is that it combines both :class and ::with-classes. In this combination, the richer syntax support of Reagent seems to be lost.

I think, at this point, it would be time to deprecate ::with-classes once and for all, i.e. remove it completely and log a warning if people use it. The feature has been marked as deprecated since version 1.3.0 (2018) and it can be easily replaced with :class. The contents of :class could be used as it is and all Reagent syntax would be supported.

By the way, the first argument of use-style also accepts ::with-classes. This is still valid, I'm only talking about the second parameter, the option map.

@Jarzka
Copy link
Owner

Jarzka commented May 26, 2020

I forgot that ::with-styles is still valid in style map (it accepts a vector of strings), so we have to combine it with :class anyway. But maybe we can still add manual support for passing keywords and vector of keywords to :class. I'm planning on adding this support in the next version.

@paintparty
Copy link
Author

Thanks!

@Jarzka
Copy link
Owner

Jarzka commented May 30, 2020

This feature is now implemented in the latest release: 2.1.1

@Jarzka Jarzka closed this as completed Jun 5, 2020
@paintparty
Copy link
Author

paintparty commented Jun 5, 2020 via email

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