bbca-forecast / ui /theme.py
nandutt's picture
Add BBCA forecast app
ed25d75 verified
Raw History Blame Contribute Delete
1.71 kB
"""Gradio theme: the same dark desk palette in light and dark mode."""
import gradio as gr
FONTS_HEAD = (
'<link rel="preconnect" href="https://fonts.googleapis.com">'
'<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'
'<link rel="stylesheet" href="https://fonts.googleapis.com/css2?'
"family=Archivo:wdth,wght@118,800&family=IBM+Plex+Mono:wght@400;500;600;700"
'&family=IBM+Plex+Sans:wght@400;500;600&display=swap">'
)
_SAME = {
"body_background_fill": "#0A0E13",
"body_text_color": "#E8EEF4",
"body_text_color_subdued": "#7F8FA0",
"background_fill_primary": "#10171F",
"background_fill_secondary": "#141D27",
"block_background_fill": "#10171F",
"block_border_color": "#1F2B37",
"block_label_text_color": "#7F8FA0",
"block_title_text_color": "#E8EEF4",
"border_color_primary": "#1F2B37",
"input_background_fill": "#0A0E13",
"input_border_color": "#1F2B37",
"slider_color": "#C8F53C",
"checkbox_background_color_selected": "#C8F53C",
"checkbox_border_color_selected": "#C8F53C",
"color_accent": "#C8F53C",
"color_accent_soft": "rgba(200,245,60,.14)",
"link_text_color": "#C8F53C",
}
def build_theme() -> gr.themes.Base:
theme = gr.themes.Base(
font=[gr.themes.GoogleFont("IBM Plex Sans"), "system-ui", "sans-serif"],
font_mono=[gr.themes.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace"],
radius_size=gr.themes.sizes.radius_md,
)
values = {}
for key, val in _SAME.items():
values[key] = val
if key != "color_accent": # the only variable without a _dark twin
values[f"{key}_dark"] = val
return theme.set(**values)