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

Addon ignores TailwindCSS dark mode #94

Open
william-ford-rq opened this issue Oct 26, 2023 · 2 comments
Open

Addon ignores TailwindCSS dark mode #94

william-ford-rq opened this issue Oct 26, 2023 · 2 comments

Comments

@william-ford-rq
Copy link

Hey! Great work on this storybook addon, I would love to use it in my project, but I found a small issue while setting it up:

As I'm building a design system using TailwindCSS in light and dark mode, I have components that will have combinations of classes like for example bg-success-700, hover:bg-success-800, and dark:hover:bg-success-600. If you're unfamiliar, this means that in any normal case I want the background color of the element to be "success-700", and the hover background color to be "success-800", but if dark mode is activated, I want the hover background color to be "success-600". You enable dark mode by adding a "dark" class to one of the component's parent elements.

However, the addon seems to ignore the dark mode this example of classes, and only shows the light mode hover behavior, even if dark mode is enabled. It seems that only the classes .hover\:bg-success-800:hover, .hover\:bg-success-800.pseudo-hover, and .pseudo-hover-all .hover\:bg-success-800 are correctly generated.

I am also seeing this class being generated: :is(.dark .dark\:hover\:bg-success-600:hover), :is(.dark .dark\.pseudo-hover\:bg-success-600.pseudo-hover), .pseudo-hover-all.pseudo-hover-all :is(), but it (especially the last one) looks a bit weird and I can only see it in my active styles when I manually enable the :hover element state from my browser devtools.

If I disable the addon, only these classes are generated by TailwindCSS: .hover\:border-success-800:hover and :is(.dark .dark\:hover\:bg-success-600:hover)

Is there currently a nice way to resolve this issue in the addon? Do you have an idea for a configuration/feature/bugfix that could solve this issue? I'm happy to submit a PR if necessary.

@apetta
Copy link

apetta commented Nov 11, 2023

+1
This is currently a blocker for me as well

@apetta
Copy link

apetta commented Nov 11, 2023

A temporary workaround is to ensure the hover/focus modifier goes first. i.e. hover:dark:bg-zinc-800 instead of dark:hover:bg-zinc-800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants