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

WindiCSS problem with CSS variables, double dash prefix is only single dash in the generated javascript files #18

Closed
gunters63 opened this issue Mar 31, 2021 · 9 comments
Labels

Comments

@gunters63
Copy link

gunters63 commented Mar 31, 2021

Hi there.

I am using DaisyUI together with Vite and WindiCSS (vite-plugin-windicss) and it is almost working.

There is one problem with CSS variables, though (Styled components and themes).
DaisyUI uses prejss-cli to convert the css into JS objects.
Strangely, during this conversion, CSS vars get mangled from:

--tw-bg-opacity

To something like this:

-TwBgOpacity

The conversion from kebab to Pascal case would be ok, windicss can handle this, the problem is the deleted dash at the start.
It only happens for CSS variables starting with double dash.

Something in the prejss-cli conversion is going wrong.

If I manually replace all -Tw with --Tw in daisyui/dist/styled.js, the styled components seem to work.

@saadeghi
Copy link
Owner

Hi,
I don't think this problem is because how prejss converts the variables because in a Tailwind project, Tailwind uses the same JS object and everything works fine. However Windi seems to read it differently.

As mentioned in this issue @marshallswain is working on the plugin (Thanks to him) and it might get fixed soon.

@gunters63
Copy link
Author

Ok, I will have a look on how tailwind processes the JS objects. Maybe the WindiCSS team can be convinced to process these the same way. Then an extra plugin would not be strictly necessary I think.

That said, I still think prejss-cli does the wrong thing here, maybe I will look into that too, just curious :)

@gunters63
Copy link
Author

I found the reason why Tailwind can handle the '-TwBgOpacity syntax':

dashify

May the WindiCSS team can adapt their parsing to match this, I will ask them :)

@gunters63
Copy link
Author

I created an issue for WindiCSS: Component generation not 100% compatible to TailwindUI with leading dashes

@gunters63
Copy link
Author

I created another issue for WindiCSS because themes break because the media style "@media (prefers-color-scheme:dark)" is moved to the end: Component generation moves media CSS styles to the end

@marshallswain
Copy link
Contributor

marshallswain commented Apr 1, 2021

@gunters63 I'm glad you confirmed the issue. I suspected it was a WindoCSS bug, but it's much better that you've identified the actual cause of the bug in windi.

@saadeghi
Copy link
Owner

saadeghi commented Apr 4, 2021

This issue seems to be fixed (windicss/windicss#218)
@gunters63 Can you please update WindiCSS to latest version (2.5.10) and confirm if it works now?

@gunters63
Copy link
Author

@saadeghi: Yes, can confirm it works now. Now there is only a little problem with theming left which I could work around (copying the CSS, removing the media prefers-dark style and importing it directly with themes: false in daisyui config).

@gunters63
Copy link
Author

Closing issue as WindiCSS is fixed now

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

No branches or pull requests

3 participants