diff --git a/index.html b/index.html index 8b82374..fc7c704 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,7 @@
-
Black
+
System
+
Light
Dark
+
Black
Ocean
Purple
Forest
diff --git a/js/storage.js b/js/storage.js index 20ef4d2..58660e4 100644 --- a/js/storage.js +++ b/js/storage.js @@ -229,8 +229,9 @@ export const themeManager = { CUSTOM_THEME_KEY: 'monochrome-custom-theme', defaultThemes: { - monochrome: {}, + light: {}, dark: {}, + monochrome: {}, ocean: {}, purple: {}, forest: {} @@ -238,15 +239,21 @@ export const themeManager = { getTheme() { try { - return localStorage.getItem(this.STORAGE_KEY) || 'monochrome'; + return localStorage.getItem(this.STORAGE_KEY) || 'system'; } catch (e) { - return 'monochrome'; + return 'system'; } }, setTheme(theme) { localStorage.setItem(this.STORAGE_KEY, theme); - document.documentElement.setAttribute('data-theme', theme); + + if (theme === 'system') { + const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light'); + } else { + document.documentElement.setAttribute('data-theme', theme); + } }, getCustomTheme() { @@ -318,3 +325,12 @@ export const lyricsSettings = { localStorage.setItem(this.DOWNLOAD_WITH_TRACKS, enabled ? 'true' : 'false'); } }; + +// System theme listener +if (typeof window !== 'undefined' && window.matchMedia) { + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { + if (themeManager.getTheme() === 'system') { + document.documentElement.setAttribute('data-theme', e.matches ? 'dark' : 'light'); + } + }); +} diff --git a/styles.css b/styles.css index 830bbdd..06391e7 100644 --- a/styles.css +++ b/styles.css @@ -114,6 +114,27 @@ --explicit-badge: #f59e0b; } +:root[data-theme="light"] { + --background: #ffffff; + --foreground: #000000; + --card: #f4f4f5; + --card-foreground: #000000; + --primary: #2563eb; + --primary-foreground: #ffffff; + --secondary: #e4e4e7; + --secondary-foreground: #000000; + --muted: #e4e4e7; + --muted-foreground: #71717a; + --border: #e4e4e7; + --input: #e4e4e7; + --ring: #2563eb; + --highlight: #2563eb; + --highlight-rgb: 37, 99, 235; + --active-highlight: var(--highlight); + --explicit-badge: #000000; + --explicit-badge-foreground: #ffffff; +} + *, *::before, *::after { box-sizing: border-box; margin: 0; @@ -178,7 +199,6 @@ kbd { flex-direction: column; gap: 2rem; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); - z-index: 2000; } .main-content { @@ -190,7 +210,7 @@ kbd { .now-playing-bar { grid-area: player; - background-color: #050505; + background-color: var(--card); border-top: 1px solid var(--border); padding: var(--spacing-md) var(--spacing-lg); display: grid; @@ -491,7 +511,7 @@ kbd { align-items: center; justify-content: center; background-color: var(--explicit-badge); - color: #000; + color: var(--explicit-badge-foreground, #000); font-size: 0.65rem; font-weight: 700; padding: 0.15rem 0.35rem; @@ -1850,6 +1870,7 @@ input:checked + .slider::before { height: 100%; transform: translateX(-100%); box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); + z-index: 2000; } .sidebar.is-open {