Skip to content

[Feature] Implement End-to-End Dark Theme Support and Title Bar Synchronization #513

Closed

Description

@khaira777

Summary & Context

FloCafe currently has complete dark-mode CSS variable definitions (.dark { ... } in frontend/src/app/globals.css) and title-bar overlay color tokens (main/title-bar-theme.ts), but there is no mechanism to toggle, persist, or apply the dark theme to the UI.

Additionally, on Electron platforms with Window Controls Overlay (Windows/macOS), the title bar caption controls initially derived their color palette directly from the OS theme (nativeTheme.shouldUseDarkColors). Because the frontend application document never applied the .dark class, a dark OS theme caused a visual mismatch where the caption buttons rendered dark while the rest of the application remained light.

This issue tracks end-to-end theme support (Light / Dark / System) across the renderer and Electron main process.


Current State & Codebase Research

  1. CSS Variables & Tokens:

    • frontend/src/app/globals.css lines 229–260 define the complete OKLCH dark palette for all UI tokens (--background, --foreground, --card, --sidebar, --border, --muted, etc.).
    • @custom-variant dark (&:is(.dark *)); is already set up for Tailwind v4.
  2. Window Controls Overlay (Electron Main Process):

    • main/title-bar-theme.ts defines TITLE_BAR_OVERLAY_COLORS for light (#ffffff / #0a0a0a) and dark (#0a0a0a / #fafafa).
    • applyTitleBarOverlayTheme(win, isDark) and attachTitleBarThemeSync(nativeTheme, getWindow) already support dynamic title bar updates at runtime for Windows and macOS.
    • main/index.ts currently pins isDark: false to avoid mismatch until the renderer theme engine is active.
  3. Settings & Persistence:

    • Allowed wildcard settings keys are defined in main/routes/settings.ts (ALLOWED_WILDCARD_KEYS) and main/ipc.ts (ALLOWED_IPC_KEYS). theme / theme_mode is not yet registered.

Architecture & Technical Requirements

1. Settings Key & Persistence (main/ & Database)

  • Register theme_mode ('light' | 'dark' | 'system') as an allowed key in:
    • main/routes/settings.ts (ALLOWED_WILDCARD_KEYS)
    • main/ipc.ts (ALLOWED_IPC_KEYS)
  • Default value: 'system' (or 'light').

2. Frontend Theme Management (frontend/src/)

  • Create a dedicated ThemeProvider or ThemeSync component (similar pattern to HtmlLangSync.tsx):
    • Listen for the active theme_mode preference from settings.
    • When set to 'system', listen to window.matchMedia('(prefers-color-scheme: dark)').
    • Toggle the .dark class on document.documentElement (<html>).
    • Broadcast the effective theme mode (light vs dark) to Electron main process via IPC so native chrome stays synchronized.

3. IPC & Title Bar Synchronization (main/ + frontend/)

  • Add an IPC channel (e.g. set-theme-mode / theme-changed) to notify the main process when the effective theme changes in the renderer.
  • On theme update:
    • Call applyTitleBarOverlayTheme(mainWindow, isDark) on Windows/macOS.
    • Update createMainWindow to use the initial persisted theme setting.

4. Settings UI (frontend/src/app/(dashboard)/settings/)

  • Add an Appearance / Theme section in Settings with:
    • Radio options or segmented button: Light, Dark, System / Auto.
    • Immediate optimistic update with rollback on failure.

Acceptance Criteria

  • Selecting Dark mode applies the .dark class to <html> and renders all components in dark palette.
  • Selecting Light mode removes .dark and renders standard light theme.
  • Selecting System dynamically responds to OS prefers-color-scheme changes.
  • Electron native title bar caption buttons (titleBarOverlay) match the active app theme on Windows and macOS.
  • Theme preference persists across app restarts and database reloads.
  • Offline-first operation: No external network calls are required for theme resolution or icon assets.
  • Standalone routes (/kds, /customer-display, /server-standalone) cleanly inherit or support theme settings without layout breakage.

Activity

  1. added
    enhancement
    on Aug 30, 2026
  2. carvalab commented on Aug 31, 2026

    @carvalab
    Contributor

    Implemented in #563. If you see any discrepancy, please let me know to improve. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions