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

Using rgb(var(--foo from '...')) gives unexpected results (in CSS modules with dashedIdents) #763

Open
evertheylen opened this issue Jun 24, 2024 · 0 comments

Comments

@evertheylen
Copy link

evertheylen commented Jun 24, 2024

I have a file colors.module.css:

:root {
  --red: rgb(255, 0, 0);
  --blue: 0, 0, 255;
}

And a file title.module.css:

.redOnBlue {
  color: var(--red from "./colors.module.css");
  background-color: rgb(var(--blue from "./colors.module.css"));
}

Which is converted to the following CSS:

.d-HkJG_redOnBlue {
  color: var(--sE19ba_red);
  background-color: rgb(var(--wtJ_Ka));
}

As you can see, the second background-color property is wrong. This seems to happen when I put var(... from ...) stuff within rgb, rgba, hsl or hsla function calls (probably others too). I would expect it to generate background-color: rgb(var(--sE19ba_blue)).

I also made a full stackblitz repro. Couldn't get the dashed identifiers to work in Parcel so I used Vite.

(Why would I ever let out the rgb in a variable? So I can set the transparency with rgba(var(--theme-primary), 0.5).)

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

1 participant