Coverage for src/lexigram/admin/theme/service.py: 23%
13 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 23:31 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 23:31 +0800
1from __future__ import annotations
3from lexigram.ui import shadcn_css
6class AdminThemeService:
7 """Generates and caches theme CSS from a configurable primary color.
9 Args:
10 primary_color: Hex color string.
11 """
13 def __init__(self, primary_color: str = "#6b7280") -> None:
14 self._primary_color = primary_color
15 self._cached_css: str | None = None
17 def generate_theme_css(self) -> str:
18 """Return the full theme CSS, cached until the color changes."""
19 if self._cached_css is None:
20 self._cached_css = shadcn_css(primary=self._primary_color)
21 return self._cached_css
23 def update_primary_color(self, color: str) -> None:
24 """Update the primary color and invalidate the CSS cache."""
25 self._primary_color = color
26 self._cached_css = None