From e525dafdd1ecbf0a52e5b569bb0f593bbbc4f9e0 Mon Sep 17 00:00:00 2001 From: diaco Date: Sun, 4 Oct 2026 08:24:38 +0330 Subject: [PATCH] Add light theme default with toggle Co-authored-by: Cursor --- slips/static/slips/css/style.css | 74 ++++++++++++++++++++++++-------- slips/static/slips/js/i18n.js | 17 ++++++++ slips/templates/slips/base.html | 11 ++++- 3 files changed, 83 insertions(+), 19 deletions(-) diff --git a/slips/static/slips/css/style.css b/slips/static/slips/css/style.css index 079867a..92e555a 100644 --- a/slips/static/slips/css/style.css +++ b/slips/static/slips/css/style.css @@ -1,8 +1,35 @@ -/* Base Variables */ +/* Base Variables — light default */ :root { + --bg-primary: #f1f5f9; + --bg-secondary: #ffffff; + --bg-glass: rgba(255, 255, 255, 0.85); + --bg-input: #f8fafc; + --bg-muted: rgba(15, 23, 42, 0.05); + --bg-hover: rgba(15, 23, 42, 0.06); + --bg-inset: #e2e8f0; + --accent: #2563eb; + --accent-glow: #3b82f6; + --success: #059669; + --warning: #d97706; + --danger: #dc2626; + --text-primary: #0f172a; + --text-secondary: #64748b; + --border: rgba(15, 23, 42, 0.1); + --shadow: rgba(15, 23, 42, 0.12); + + --font-sans: 'Inter', sans-serif; + --font-fa: 'Vazirmatn', sans-serif; + --font-mono: 'JetBrains Mono', monospace; +} + +[data-theme="dark"] { --bg-primary: #0f172a; --bg-secondary: #1e293b; --bg-glass: rgba(30, 41, 59, 0.7); + --bg-input: rgba(15, 23, 42, 0.5); + --bg-muted: rgba(0, 0, 0, 0.2); + --bg-hover: rgba(255, 255, 255, 0.05); + --bg-inset: rgba(15, 23, 42, 0.4); --accent: #3b82f6; --accent-glow: #60a5fa; --success: #10b981; @@ -11,10 +38,7 @@ --text-primary: #f1f5f9; --text-secondary: #94a3b8; --border: rgba(148, 163, 184, 0.1); - - --font-sans: 'Inter', sans-serif; - --font-fa: 'Vazirmatn', sans-serif; - --font-mono: 'JetBrains Mono', monospace; + --shadow: rgba(0, 0, 0, 0.3); } /* Reset & Base */ @@ -24,6 +48,14 @@ box-sizing: border-box; } +html { + color-scheme: light; +} + +html[data-theme="dark"] { + color-scheme: dark; +} + body { font-family: var(--font-sans); background-color: var(--bg-primary); @@ -99,6 +131,12 @@ html[lang="fa"] body { border-bottom: 2px solid var(--accent); } +.nav-actions { + display: flex; + align-items: center; + gap: 0.5rem; +} + /* Layout */ .main-content { max-width: 1200px; @@ -180,7 +218,7 @@ input, select { width: 100%; min-width: 0; box-sizing: border-box; - background: rgba(15, 23, 42, 0.5); + background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary); padding: 0.75rem 1rem; @@ -206,7 +244,7 @@ input:focus, select:focus { } .sub-panel { - background: rgba(0, 0, 0, 0.2); + background: var(--bg-muted); padding: 1rem; border-radius: 8px; margin-top: 0.5rem; @@ -263,7 +301,7 @@ input:focus, select:focus { } .btn-ghost:hover { - background: rgba(255, 255, 255, 0.05); + background: var(--bg-hover); color: var(--text-primary); } @@ -296,7 +334,7 @@ input:focus, select:focus { font-weight: 500; color: var(--text-secondary); font-size: 0.875rem; - background: rgba(0, 0, 0, 0.2); + background: var(--bg-muted); } .data-table tbody tr { @@ -304,7 +342,7 @@ input:focus, select:focus { } .data-table tbody tr:hover { - background: rgba(255, 255, 255, 0.02); + background: var(--bg-hover); } .empty-state { @@ -331,10 +369,10 @@ input:focus, select:focus { .badge-done { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); } .badge-cancelled { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); } .badge-accent { background: rgba(59, 130, 246, 0.1); color: var(--accent-glow); border: 1px solid rgba(59, 130, 246, 0.2); } -.badge-neutral { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); border: 1px solid var(--border); } +.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); } .card-badge { - background: rgba(0,0,0,0.3); + background: var(--bg-muted); padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.875rem; @@ -350,13 +388,13 @@ input:focus, select:focus { } .queue-item { - background: rgba(15, 23, 42, 0.4); + background: var(--bg-inset); transition: transform 0.2s, box-shadow 0.2s; } .queue-item:hover { transform: translateY(-2px); - box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3); + box-shadow: 0 10px 15px -3px var(--shadow); border-color: rgba(59, 130, 246, 0.3); } @@ -366,7 +404,7 @@ input:focus, select:focus { align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); - background: rgba(0, 0, 0, 0.2); + background: var(--bg-muted); } .queue-item-body { @@ -411,7 +449,7 @@ input:focus, select:focus { .queue-item-actions { padding: 1rem 1.5rem; - background: rgba(0, 0, 0, 0.2); + background: var(--bg-muted); border-top: 1px solid var(--border); display: flex; gap: 1rem; @@ -427,10 +465,10 @@ input:focus, select:focus { bottom: 2rem; right: 2rem; background: var(--bg-secondary); - color: white; + color: var(--text-primary); padding: 1rem 1.5rem; border-radius: 8px; - box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3); + box-shadow: 0 10px 15px -3px var(--shadow); border-left: 4px solid var(--accent); transform: translateY(calc(100% + 2rem)); opacity: 0; diff --git a/slips/static/slips/js/i18n.js b/slips/static/slips/js/i18n.js index 45593ad..f42bedb 100644 --- a/slips/static/slips/js/i18n.js +++ b/slips/static/slips/js/i18n.js @@ -84,6 +84,22 @@ const translations = { }; let currentLang = localStorage.getItem('slip_lang') || 'en'; +let currentTheme = localStorage.getItem('slip_theme') || 'light'; + +function applyTheme(theme) { + document.documentElement.setAttribute('data-theme', theme); + const label = document.getElementById('theme-label'); + if (label) { + // show the theme you'll switch to + label.textContent = theme === 'light' ? '🌙' : '☀️'; + } +} + +function toggleTheme() { + currentTheme = currentTheme === 'light' ? 'dark' : 'light'; + localStorage.setItem('slip_theme', currentTheme); + applyTheme(currentTheme); +} function applyLanguage(lang) { document.documentElement.lang = lang; @@ -130,5 +146,6 @@ function showToast(message, isError = false) { // Initialize on load document.addEventListener('DOMContentLoaded', () => { + applyTheme(currentTheme); applyLanguage(currentLang); }); diff --git a/slips/templates/slips/base.html b/slips/templates/slips/base.html index 0c0dd5b..026f672 100644 --- a/slips/templates/slips/base.html +++ b/slips/templates/slips/base.html @@ -11,6 +11,12 @@ + {% block extra_head %}{% endblock %} @@ -26,7 +32,10 @@ Calibrate -- 2.49.1