From f0b575ab2ffd732a9957798305b18c83883bc15e Mon Sep 17 00:00:00 2001 From: liruifengv Date: Wed, 3 Apr 2024 14:11:58 +0800 Subject: [PATCH 1/4] fix: save `localStorage.astroErrorOverlayTheme` when detected dark mode --- packages/astro/src/core/errors/overlay.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts index 282c79cd6a21..fb219550aae3 100644 --- a/packages/astro/src/core/errors/overlay.ts +++ b/packages/astro/src/core/errors/overlay.ts @@ -593,6 +593,7 @@ 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'); From aa672b2802b1f78aac0a9a34f86fbcb81aa57c4f Mon Sep 17 00:00:00 2001 From: liruifengv Date: Wed, 3 Apr 2024 14:14:17 +0800 Subject: [PATCH 2/4] add changeset --- .changeset/short-flies-itch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/short-flies-itch.md diff --git a/.changeset/short-flies-itch.md b/.changeset/short-flies-itch.md new file mode 100644 index 000000000000..0e4ce75999a3 --- /dev/null +++ b/.changeset/short-flies-itch.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +save `localStorage.astroErrorOverlayTheme` when detected dark mode From 9e2e7db5c5a862b2fa56fdff4039256404f853fe Mon Sep 17 00:00:00 2001 From: liruifengv Date: Wed, 3 Apr 2024 14:22:39 +0800 Subject: [PATCH 3/4] Fix theme toggle in ErrorOverlay --- packages/astro/src/core/errors/overlay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts index fb219550aae3..9bfc562ba46f 100644 --- a/packages/astro/src/core/errors/overlay.ts +++ b/packages/astro/src/core/errors/overlay.ts @@ -600,7 +600,7 @@ class ErrorOverlay extends HTMLElement { 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'; }); From 1c71fb9cb35f80cdb6b907f60c9928742a898f61 Mon Sep 17 00:00:00 2001 From: liruifengv Date: Wed, 3 Apr 2024 14:25:39 +0800 Subject: [PATCH 4/4] update changeset --- .changeset/short-flies-itch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/short-flies-itch.md b/.changeset/short-flies-itch.md index 0e4ce75999a3..929bdec522aa 100644 --- a/.changeset/short-flies-itch.md +++ b/.changeset/short-flies-itch.md @@ -2,4 +2,4 @@ "astro": patch --- -save `localStorage.astroErrorOverlayTheme` when detected dark mode +Fixed errorOverlay theme toggle bug.