From 8dcb81f5af142e14a46a60aab4e37ac7c79d3b24 Mon Sep 17 00:00:00 2001 From: spde3289 Date: Tue, 3 Mar 2026 16:57:50 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=ED=85=8C=EB=A7=88=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/_components/ThemeScript.tsx | 23 +++++++++++++++++++++++ src/app/layout.tsx | 7 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/app/_components/ThemeScript.tsx diff --git a/src/app/_components/ThemeScript.tsx b/src/app/_components/ThemeScript.tsx new file mode 100644 index 0000000..8530c45 --- /dev/null +++ b/src/app/_components/ThemeScript.tsx @@ -0,0 +1,23 @@ +export const ThemeScript = () => { + const codeToRunOnClient = `(() => { + try { + const storedTheme = localStorage.getItem('theme'); + const theme = storedTheme === 'light' || storedTheme === 'dark' ? storedTheme : 'system'; + + const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + const resolvedTheme = theme === 'system' ? (systemPrefersDark ? 'dark' : 'light') : theme; + + if (resolvedTheme === 'dark') { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + } catch (e) { + console.error(e) + } + })();`; + + return