From 164d900dff9e16e4f0f101804745ea9b77d7394c Mon Sep 17 00:00:00 2001 From: pulnip Date: Sat, 12 Jul 2025 12:50:24 +0900 Subject: [PATCH] fix flash effect --- _includes/Footer.html | 4 ++++ assets/css/style.css | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_includes/Footer.html b/_includes/Footer.html index ee18f11c..072addd8 100644 --- a/_includes/Footer.html +++ b/_includes/Footer.html @@ -20,6 +20,7 @@
// Theme toggle const themeToggle = document.querySelector('.theme-toggle'); const root = document.documentElement; + const body = document.body; function setTheme(theme) { root.setAttribute('data-theme', theme); @@ -33,6 +34,9 @@
} themeToggle.addEventListener('click', function() { + root.classList.add('theme-transition'); + body.classList.add('theme-transition'); + const isDark = root.getAttribute('data-theme') === 'dark'; setTheme(isDark ? 'light' : 'dark'); }); diff --git a/assets/css/style.css b/assets/css/style.css index b75cc61b..ffba1f61 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -39,7 +39,9 @@ --border: #33343a; } -html, body { +/* smooth transition on theme switching */ +html.theme-transition, +body.theme-transition { transition: background 0.3s, color 0.3s; }