From 1da8ae56c4e393736fc8519131e245c7520e7a1e Mon Sep 17 00:00:00 2001 From: grassblock Date: Sat, 3 May 2025 18:04:08 +0800 Subject: [PATCH] feat: better dark mode switch --- src/components/ThemeSwitcher.astro | 38 +++++++++++++++++++++++------- src/styles/global.css | 29 ++++++++++++++++++++++- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/components/ThemeSwitcher.astro b/src/components/ThemeSwitcher.astro index 6e6d349..8fa544a 100644 --- a/src/components/ThemeSwitcher.astro +++ b/src/components/ThemeSwitcher.astro @@ -5,18 +5,38 @@ \ No newline at end of file diff --git a/src/styles/global.css b/src/styles/global.css index eaf49e8..f9f07d1 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -11,7 +11,30 @@ --terminal-red: #ef4444; --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } - +/* Light theme */ +@media (prefers-color-scheme: light) { + :root { + --bg-color: #f3f4f6; + --text-color: #374151; + --accent-color: #3b82f6; + --border-color: #d1d5db; + --header-color: #1f2937; + --terminal-green: #059669; + --terminal-yellow: #d97706; + --terminal-red: #dc2626; + } + :root:not([data-theme="light"]) { + --bg-color: #1f2937; + --text-color: #a5b4cf; + --accent-color: #64a0ff; + --border-color: #3b4351; + --header-color: #83a2ce; + --terminal-green: #4ade80; + --terminal-yellow: #fbbf24; + --terminal-red: #ef4444; + } +} +/* Light theme override (for switch) */ :root[data-theme="light"] { --bg-color: #f3f4f6; --text-color: #374151; @@ -116,6 +139,10 @@ main { opacity: 0.7; } +.footer img { + vertical-align: middle; +} + /* Post styles */ .post-title { color: var(--header-color);