Coverage for src / puzzletree / utils / theme / theme.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-12 20:35 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-12 20:35 +0000
1"""Theme configuration for Rich terminal output."""
3from typing import Any
5from catppuccin import PALETTE
6from rich.style import Style # noqa: TC002 - Style is used at runtime in dict type annotation, not just type checking
7from rich.theme import Theme
10def _create_theme(colors: Any) -> Theme:
11 styles: dict[str, Style | str] = {
12 "rosewater": colors.rosewater.hex,
13 "flamingo": colors.flamingo.hex,
14 "pink": colors.pink.hex,
15 "mauve": colors.mauve.hex,
16 "red": colors.red.hex,
17 "maroon": colors.maroon.hex,
18 "peach": colors.peach.hex,
19 "yellow": colors.yellow.hex,
20 "green": colors.green.hex,
21 "teal": colors.teal.hex,
22 "sky": colors.sky.hex,
23 "sapphire": colors.sapphire.hex,
24 "blue": colors.blue.hex,
25 "lavender": colors.lavender.hex,
26 "text": colors.text.hex,
27 "subtext1": colors.subtext1.hex,
28 "subtext0": colors.subtext0.hex,
29 "overlay2": colors.overlay2.hex,
30 "overlay1": colors.overlay1.hex,
31 "overlay0": colors.overlay0.hex,
32 "surface2": colors.surface2.hex,
33 "surface1": colors.surface1.hex,
34 "surface0": colors.surface0.hex,
35 "base": colors.base.hex,
36 "mantle": colors.mantle.hex,
37 "crust": colors.crust.hex,
38 }
40 return Theme(styles=styles, inherit=True)
43def set_theme(theme_name: str = "dark") -> Theme:
44 """Set the theme for the application."""
45 if theme_name == "light":
46 theme = _create_theme(PALETTE.frappe.colors)
47 elif theme_name == "dark":
48 theme = _create_theme(PALETTE.mocha.colors)
49 else:
50 raise ValueError(f"Unknown theme: {theme_name}")
51 return theme