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

Wrong CSS generated #185

Closed
tqwewe opened this issue Aug 14, 2023 · 7 comments
Closed

Wrong CSS generated #185

tqwewe opened this issue Aug 14, 2023 · 7 comments

Comments

@tqwewe
Copy link

tqwewe commented Aug 14, 2023

I am using a simple css file:

.btn:is(input[type="checkbox"]),
.btn:is(input[type="radio"]) {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

However, when building with cargo leptos build, it generates the following css in target/site/pkg/app.css:

.btninput[type="checkbox"], .btninput[type="radio"] {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
@aperepel
Copy link
Collaborator

Hi, what's your project set up like? Is there Sass processing configured or anything like that?

@tqwewe
Copy link
Author

tqwewe commented Aug 20, 2023

It's using tailwind with postcss, using npx tailwind. The tailwind install is essentially default with DaisyUI, though I don't think the preprocessors would be causing any issues as the CSS snippets I posted are after any preprocessing is done.

To fix it temporarily, I cloned cargo leptos and added a new config to ignore processing css, so it simply copies the file without any browserquery or anything.

@aperepel
Copy link
Collaborator

I don't believe this has anything to do with cargo leptos. Tried a quick test, and tailwindcss doesn't mangle it either. Something is going on with pre-/post-processing in your config, I'd look there. Here's a quick rundown of what I tried:

❯ cat input.css
.btn:is(input[type="checkbox"]),
.btn:is(input[type="radio"]) {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
❯ /Users/agrande/Library/Caches/cargo-leptos/tailwindcss-v3.3.3/tailwindcss-v3.3.3/tailwindcss-macos-arm64 -i input.css -o output.css

Rebuilding...

Done in 59ms.
❯ ll
total 16
-rw-r--r--  1 agrande  wheel   154B Aug 20 11:12 input.css
-rw-r--r--  1 agrande  wheel   154B Aug 20 11:12 output.css
❯ cat output.css
.btn:is(input[type="checkbox"]),
.btn:is(input[type="radio"]) {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
❯ diff -u input.css output.css
❯ ll
total 16
-rw-r--r--  1 agrande  wheel   154B Aug 20 11:12 input.css
-rw-r--r--  1 agrande  wheel   154B Aug 20 11:12 output.css

@prscoelho
Copy link
Contributor

prscoelho commented Sep 18, 2023

Does #194 fix your issue?

EDIT: nevermind, it shouldn't. Regardless, it's lightningcss that converts the names: playground

@prscoelho
Copy link
Contributor

Coming back to this, I think this would be the more "standard" css:

input[type="checkbox"].btn, input[type="radio"].btn {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

And then when you add :is():

:is(input[type="checkbox"], input[type="radio"]).btn {
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

Lightningcss parses these correctly. Your version as is works in the browser, but is a bit unusual, the class selector goes after the attribute usually while yours is reversed.

@tqwewe
Copy link
Author

tqwewe commented Oct 10, 2023

Thank you for the input @prscoelho
The CSS I posted is actually generated from tailwind with DiasyUI.
Even if it might be "unusual", it's still correct accoring to the spec I believe, so should still be considered a bug within lightningcss

@benwis
Copy link
Contributor

benwis commented Jan 12, 2024

Closing as this is an issue with lightningcss and not us. Feel free to open an issue there

@benwis benwis closed this as completed Jan 12, 2024
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

4 participants