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

refactor: generate presets with css cascade layers #4894

Merged
merged 3 commits into from
Feb 22, 2025
Merged

Conversation

TrySound
Copy link
Member

@TrySound TrySound commented Feb 19, 2025

Closes #4796

CSS Cascade Layers are already widely support for almost 3 years. See https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

We can switch to it instead of wrapping selectors with :where all preset selectors.

For older browsers impact will be insignificant as in most cases we use presets only to normalize browser styles.

Generated code now looks like this

@layer presets {
  div.w-box {
    display: block;
  }
}

Here's how presets look in chrome devtools. As you can see browser styles are defined as layer too.

Screenshot 2025-02-19 at 17 14 23

Closes #4796

CSS Cascade Layers are already widely support for almost 3 years.
See https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

We can switch to it instead of wrapping selectors with `:where`
all preset selectors.

For older browsers impact will be insignificant as in most cases we use
presets only to normalize browser styles.

Generated code now looks like this

```css
@layer presets {
  div.w-box {
    display: block;
  }
}
```
@TrySound TrySound merged commit 326275f into main Feb 22, 2025
29 checks passed
@TrySound TrySound deleted the layers.staging branch February 22, 2025 05:45
istarkov pushed a commit that referenced this pull request Feb 23, 2025
Closes #4796

CSS Cascade Layers are already widely support for almost 3 years. See
https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

We can switch to it instead of wrapping selectors with `:where` all
preset selectors.

For older browsers impact will be insignificant as in most cases we use
presets only to normalize browser styles.

Generated code now looks like this

```css
@layer presets {
  div.w-box {
    display: block;
  }
}
```

Here's how presets look in chrome devtools. As you can see browser
styles are defined as layer too.

<img width="357" alt="Screenshot 2025-02-19 at 17 14 23"
src="https://github.com/user-attachments/assets/473f2c0e-c7c5-4011-ba6b-4eeb1b805039"
/>
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

Successfully merging this pull request may close these issues.

Switch to cascade layers for presets in generated css
3 participants