-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CSS variables should be scoped #14678
Comments
This probably breaks more than one thing. For instance my @wjfe/dataview component, which is styled by defining CSS variables. Is there a specific case you have in mind where this is needed? What would be the way to use them unscoped? Like in here: .some-class {
background-color: rgba(var(--bs-bg-color-rgb), var(--bs-bg-opacity));
} I suppose that those would be rendered as: .some-class {
background-color: rgba(var(--bs-bg-color-rgb-HASH), var(--bs-bg-opacity-HASH));
} Then what syntax would be feasible to make them global? .some-class {
background-color: rgba(var(:global(--bs-bg-color-rgb)), var(:global(--bs-bg-opacity)));
} Like that, maybe? I'm not sure if I like this or not. I'm on the fence. If I were the one writing the parsing code, I would hate it, though. 😄 |
I never needed it, and even the opposite, I have written code that relies on the fact that CSS variables keep their names - I used them to adjust some styling in child components. |
This sounds like a bad idea. CSS vars shouldn't be scoped any more than component props should be scoped. |
Maybe instead of automatically scoping, there was a |
The main use for CSS variables is dependency injection, making them scoped destroys this use |
But I think it's possible to argue the case for variables declared with @Property specifically, and make them global when declared inside a :global{} block. |
Describe the bug
When using CSS variables, they are not scoped correctly. Their names should have the component's CSS hash appended to it to avoid scoping issues.
Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: