Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

2.7 KB
Raw Blame
"""
Theme Schema - Data structures for theme metadata.
"""

from dataclasses import dataclass
from pathlib import Path
from typing import Literal


# Required CSS variables that every theme must define
REQUIRED_VARIABLES: list[str] = [
    "--bg-primary",
    "--bg-secondary",
    "--bg-tertiary",
    "--accent-primary",
    "--accent-secondary",
    "--accent-tertiary",
    "--text-primary",
    "--text-secondary",
    "--text-muted",
    "--border-color",
    "--success-color",
    "--warning-color",
    "--error-color",
]

# Light palettes darken the status colors so they read as text on pale
# surfaces, so each must also say which ink sits on a filled accent, a filled
# warning, a filled error and a filled success, and how strong an input edge
# is. Dark
# palettes inherit the styles.css defaults (the shipped ones also set
# --text-on-accent, since white is too faint on their light accents).
LIGHT_THEME_REQUIRED_VARIABLES: list[str] = [
    "--control-border",
    "--text-on-accent",
    "--text-on-warning",
    "--text-on-error",
    "--text-on-success",
]

# RGB variants for rgba() usage
REQUIRED_RGB_VARIANTS: list[str] = [
    "--bg-primary-rgb",
    "--bg-secondary-rgb",
    "--bg-tertiary-rgb",
    "--accent-primary-rgb",
    "--accent-secondary-rgb",
    "--accent-tertiary-rgb",
    "--text-primary-rgb",
    "--text-secondary-rgb",
    "--text-muted-rgb",
    "--border-color-rgb",
    "--success-color-rgb",
    "--warning-color-rgb",
    "--error-color-rgb",
]

# Valid theme groups
ThemeGroup = Literal["core", "nature", "dev", "research", "system", "other"]

# Valid theme types (for luminance classification)
ThemeType = Literal["dark", "light"]


@dataclass
class ThemeMetadata:
    """Theme metadata extracted from CSS frontmatter."""

    id: str  # kebab-case identifier (e.g., "nord", "dracula")
    label: str  # Display label for UI (e.g., "Nord", "Dracula")
    icon: str  # FontAwesome icon class (e.g., "fa-snowflake")
    group: ThemeGroup  # Category for grouping in UI
    type: ThemeType = "dark"  # dark/light for luminance classification
    description: str = ""  # Optional description
    author: str = ""  # Optional author attribution
    css_path: Path | None = (
        None  # Path to CSS file (None for virtual themes like "system")
    )

    def to_dict(self) -> dict:
        """Convert to dictionary for JSON serialization."""
        return {
            "label": self.label,
            "icon": self.icon,
            "group": self.group,
            "type": self.type,
        }


# Group labels for UI display
GROUP_LABELS: dict[str, str] = {
    "core": "Core Themes",
    "nature": "Nature",
    "dev": "Developer Themes",
    "research": "Research & Reading",
    "system": "System",
    "other": "Other",
}