Implement .wa-invert, closes #497 (#508)

This commit is contained in:
Lea Verou
2025-01-14 10:04:27 -05:00
committed by GitHub
parent 40648e15fb
commit 01210ef364
15 changed files with 43 additions and 19 deletions

View File

@@ -91,11 +91,6 @@ const colorScheme = new ThemeAspect({
domChange(() => {
let dark = this.computedValue === 'dark';
document.documentElement.classList.toggle(`wa-dark`, dark);
for (let el of document.querySelectorAll('.wa-invert')) {
el.classList.toggle('wa-dark', !dark);
el.classList.toggle('wa-light', dark);
}
});
},
});

View File

@@ -21,7 +21,8 @@ If you're customizing the default light styles, scope your styles to the followi
:where(:root),
:host,
.wa-theme-default,
.wa-light {
.wa-light,
.wa-dark .wa-invert {
/* your custom styles here */
}
```
@@ -30,6 +31,7 @@ If you're customizing the default dark styles, scope your styles to the followin
```css
.wa-dark,
.wa-invert,
:is(:host-context(.wa-dark)) {
/* your custom styles here */
}

View File

@@ -22,6 +22,7 @@ Please note that if you import multiple themes, the last one will be the default
Each theme may also include both light and dark color schemes with the classes `wa-light` and `wa-dark`.
You can use these classes to apply a specific color scheme to an entire page or just a section.
You can also use `wa-invert` which behaves like `wa-dark` in light mode, and like `wa-light` in dark mode.
In pre-made themes, we use a light color scheme by default.
@@ -36,11 +37,13 @@ For example, the default theme is set up like this:
:where(:root),
:host,
.wa-theme-default,
.wa-light {
.wa-light,
.wa-dark .wa-invert {
/* all CSS custom properties for color, typography, space, etc. */
}
.wa-dark,
.wa-invert,
:host-context(.wa-dark) {
/* subset of CSS custom properties for a dark color scheme */
}