"""Design tokens and CSS of the FLAIRD dashboard. A restrained navy and teal palette, light evidence cards, and responsive spacing. """ from __future__ import annotations from pathlib import Path import gradio as gr TOKENS: dict[str, str] = { "primary": "#2457A7", "primary_dark": "#142D50", "accent": "#087F8C", "page_bg": "#F3F6FA", "card_bg": "#FFFFFF", "panel_bg": "#F1F5FA", "text": "#172B46", "text_muted": "#53657D", "muted_series": "#A9B5C1", "track": "#E6ECF3", "good": "#187449", "fair": "#E8B547", "poor": "#C62828", "machine": "#C54C38", "human": "#087F8C", } FONT_STACK = "Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif" # Loaded in : Inter from Google Fonts (falls back to the system font offline) and a # script that pins the light color scheme so the dashboard looks the same everywhere. HEAD = """ """ def build_css() -> str: """Return the dashboard CSS with the design tokens injected as CSS variables.""" variables = "\n".join(f" --{k.replace('_', '-')}: {v};" for k, v in TOKENS.items()) body = (Path(__file__).parent / "style.css").read_text(encoding="utf-8") return f":root {{\n{variables}\n --font: {FONT_STACK};\n}}\n{body}" def build_theme() -> gr.themes.Base: """Gradio base theme aligned with the tokens (component-level details live in the CSS).""" return gr.themes.Base( primary_hue=gr.themes.Color( c50="#EAF1FB", c100="#D5E3F6", c200="#ABC7ED", c300="#7EA7DD", c400="#4F83C8", c500="#2F66AD", c600="#2457A7", c700="#1A4580", c800="#153866", c900="#102B4F", c950="#0B1E38", ), neutral_hue="slate", font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"], ).set( body_background_fill=TOKENS["page_bg"], body_text_color=TOKENS["text"], body_text_color_subdued=TOKENS["text_muted"], block_info_text_color=TOKENS["text_muted"], block_label_text_color=TOKENS["text"], button_primary_background_fill=TOKENS["primary"], button_primary_background_fill_hover=TOKENS["primary_dark"], button_primary_text_color="#FFFFFF", block_radius="12px", input_radius="10px", )