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

chain classes for matching P3 themes #841

Open
jjenzz opened this issue Oct 18, 2024 · 1 comment
Open

chain classes for matching P3 themes #841

jjenzz opened this issue Oct 18, 2024 · 1 comment

Comments

@jjenzz
Copy link

jjenzz commented Oct 18, 2024

if we have two selectors with matching P3 themes, would it be possible to chain the selectors to reduce some of the duplication?

CleanShot 2024-10-18 at 12 24 32

i was hoping for output like:

:root, [data-theme="light"] {
  --color_violet10: #654dc4;
  --color_violet11: #6550b9;
  --color_violet9: #6e56cf;
  --color_white: #fff;
}

@supports (color: color(display-p3 0 0 0)) {
  :root, [data-theme="light"] {
    --color_violet10: color(display-p3 .381 .306 .741);
    --color_violet11: color(display-p3 .383 .317 .702);
    --color_violet9: color(display-p3 .417 .341 .784);
    --color_white: color(display-p3 1 1 1);
  }
}

i can workaround this myself ofc in the meantime, but thought it might be a nice improvement ☺️

@devongovett
Copy link
Member

what happens is that we process the first rule (:root), that generates a @supports rule after it, then we process the second rule ([data-theme="light"]), and at this point, it is no longer adjacent with the original :root rule so can no longer be merged (normally that could cause ordering issues).

So this would either require lookahead, to determine that the next rule is the same, and merge them before adding the @supports fallback, or somehow tracking that the @supports rule was generated and not in the original stylesheet and therefore does not affect order.

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

5 participants
@devongovett @jjenzz and others