From a63f3fb5ffe2247408acaaa97eca78fd59eb5686 Mon Sep 17 00:00:00 2001 From: scriptos Date: Tue, 7 Apr 2026 22:14:56 +0200 Subject: [PATCH] feat: add 5 theme pairs (ocean, forest, sunset, rose, nord) with light/dark/auto modes\n\n- Override Tabler dark-mode surface/border CSS variables per theme to remove blue tint\n- Add theme accent colors for badges, buttons, links, forms\n- Make Ocean the default theme, auto-migrate legacy values (auto/light/dark)\n- Update settings dropdown with grouped theme options\n- Update user-guide docs with new theme descriptions" --- docs/user-guide.md | 16 +- internal/auth/auth.go | 22 ++- web/templates/layout/base.html | 303 ++++++++++++++++++++++++++++++--- web/templates/settings.html | 30 +++- 4 files changed, 342 insertions(+), 29 deletions(-) diff --git a/docs/user-guide.md b/docs/user-guide.md index 361e07e..7932234 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -88,11 +88,23 @@ Navigate to **Settings** to manage your account: ### Theme -Choose between: -- **Auto** — Follows your system/browser preference +KeyWarden offers five color themes, each available in three modes: + +| Theme | Description | +|-------|-------------| +| **Ocean** (default) | Cyan/teal accent | +| **Forest** | Green accent | +| **Sunset** | Amber/orange accent | +| **Rose** | Pink accent | +| **Nord** | Cool blue-gray accent | + +Each theme supports: +- **System** — Follows your system/browser preference (light or dark) - **Light** — Always light mode - **Dark** — Always dark mode +> Existing installations using the previous theme values (`auto`, `light`, `dark`) are automatically migrated to the Ocean theme. + ### Password Change Change your password. The new password must comply with the configured password policy (displayed on the form). diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 8f5ce8e..8221f32 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -401,10 +401,26 @@ func (s *Service) DisableMFA(userID int64) error { return err } -// UpdateTheme updates the user's theme preference (auto, light, dark) +// UpdateTheme updates the user's theme preference func (s *Service) UpdateTheme(id int64, theme string) error { - if theme != "auto" && theme != "light" && theme != "dark" { - theme = "auto" + // Map legacy default values to ocean + switch theme { + case "auto", "": + theme = "ocean-auto" + case "light": + theme = "ocean-light" + case "dark": + theme = "ocean-dark" + } + validThemes := map[string]bool{ + "ocean-auto": true, "ocean-light": true, "ocean-dark": true, + "forest-auto": true, "forest-light": true, "forest-dark": true, + "sunset-auto": true, "sunset-light": true, "sunset-dark": true, + "rose-auto": true, "rose-light": true, "rose-dark": true, + "nord-auto": true, "nord-light": true, "nord-dark": true, + } + if !validThemes[theme] { + theme = "ocean-auto" } _, err := s.db.Exec( `UPDATE users SET theme = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?`, diff --git a/web/templates/layout/base.html b/web/templates/layout/base.html index b0fd1c7..02c5ee2 100644 --- a/web/templates/layout/base.html +++ b/web/templates/layout/base.html @@ -12,21 +12,31 @@ @@ -558,14 +796,36 @@