mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix: Fixed errorOverlay theme toggle bug. (#10661)
* fix: save `localStorage.astroErrorOverlayTheme` when detected dark mode * add changeset * Fix theme toggle in ErrorOverlay * update changeset
This commit is contained in:
parent
0fec72b35c
commit
e2cd7f4291
2 changed files with 7 additions and 1 deletions
5
.changeset/short-flies-itch.md
Normal file
5
.changeset/short-flies-itch.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fixed errorOverlay theme toggle bug.
|
|
@ -593,13 +593,14 @@ class ErrorOverlay extends HTMLElement {
|
|||
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
this?.classList.add('astro-dark');
|
||||
localStorage.astroErrorOverlayTheme = 'dark';
|
||||
themeToggle!.checked = true;
|
||||
} else {
|
||||
this?.classList.remove('astro-dark');
|
||||
themeToggle!.checked = false;
|
||||
}
|
||||
themeToggle?.addEventListener('click', () => {
|
||||
const isDark = localStorage.astroErrorOverlayTheme === 'dark';
|
||||
const isDark = localStorage.astroErrorOverlayTheme === 'dark' || this?.classList.contains('astro-dark');
|
||||
this?.classList.toggle('astro-dark', !isDark);
|
||||
localStorage.astroErrorOverlayTheme = isDark ? 'light' : 'dark';
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue