Skip to content

Commit 88a854d

Browse files
cursoragentZeta611
andcommitted
Refactor ThemeToggle component formatting and improve readability
Co-authored-by: jaeho.lee <jaeho.lee@snu.ac.kr>
1 parent 6d2def1 commit 88a854d

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

components/navigation/ThemeToggle.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ export default function ThemeToggle() {
2626
useEffect(() => {
2727
const cookieTheme = getCookie(THEME_COOKIE_NAME) as ThemeMode | null;
2828
// Prefer cookie; otherwise fall back to system preference on first load.
29-
const systemPrefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
30-
const initialTheme: ThemeMode = cookieTheme ?? (systemPrefersDark ? "dark" : "light");
29+
const systemPrefersDark =
30+
window.matchMedia &&
31+
window.matchMedia("(prefers-color-scheme: dark)").matches;
32+
const initialTheme: ThemeMode =
33+
cookieTheme ?? (systemPrefersDark ? "dark" : "light");
3134
document.documentElement.classList.toggle("dark", initialTheme === "dark");
3235
setTheme(initialTheme);
3336
}, []);
@@ -50,8 +53,12 @@ export default function ThemeToggle() {
5053
aria-label={theme === "dark" ? "라이트 모드로 전환" : "다크 모드로 전환"}
5154
className="text-muted-foreground"
5255
onClick={toggle}
53-
>
54-
{theme === "dark" ? <Sun className="size-5" /> : <Moon className="size-5" />}
56+
>
57+
{theme === "dark" ? (
58+
<Sun className="size-5" />
59+
) : (
60+
<Moon className="size-5" />
61+
)}
5562
</Button>
5663
);
57-
}
64+
}

0 commit comments

Comments
 (0)