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

CSS Cascade Layers support #50

Closed
AlexandrHoroshih opened this issue Sep 5, 2023 · 2 comments · Fixed by #51
Closed

CSS Cascade Layers support #50

AlexandrHoroshih opened this issue Sep 5, 2023 · 2 comments · Fixed by #51
Assignees

Comments

@AlexandrHoroshih
Copy link
Contributor

Relates to #26

Hello and thank you for the awesome library! 👋

Since CSS Cascade Layers support is gettng better in the browsers, i was wondering if there any plans to support this feature?

Right now it seems to be not supported:
I wrote some snapshot tests and current version of used-styles just adds all @layer-related stuff into the critiical styles without considering, if any of styles in that layer are actually used

So it looks like that some special handling, like it is done for @media rules, is needed 🤔

There is a polyfill for CSS Layers and it does work much better with used-styles, but since this feature is getting wider support in the browsers (90% according to caniuse), i think, it is a good time to introduce a native support

CSS Layers are pretty cool, since by using it

Authors can create layers to represent element defaults, third-party libraries, themes, components, overrides, and other styling concerns – and are able to re-order the cascade of layers in an explicit way, without altering selectors or specificity within each layer, or relying on source-order to resolve conflicts across layers

which is basically a native CSS solution to issue #26

What do you think?

@AlexandrHoroshih
Copy link
Contributor Author

AlexandrHoroshih commented Sep 5, 2023

I see a possible way to support CSS Layers as follows:

  1. layer order definitions are treated the same way as tag-based selectors (html, body, etc.), so things like @layer theme, layout, utilities; are always included in critical css
  2. "Layered" styles ( @layer theme { ... }) are handled the same way @media is handled now

If PR with this feature would be welcome, I'd be happy to work on it 🙂

@theKashey
Copy link
Owner

theKashey commented Sep 7, 2023

Absolutely correct

If PR with this feature would be welcome, I'd be happy to work on it 🙂

Yes please, my capacity is quite limited now. I even answering to issues a couple of days late 😿

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