"""Futuristic theme injection for Streamlit.""" import streamlit as st from pathlib import Path THEME_MODES = ("black", "white") def get_theme_mode() -> str: """Read the active theme from session state. Defaults to ``"black"``.""" mode = st.session_state.get("ui_theme_mode", "black") return mode if mode in THEME_MODES else "black" def set_theme_mode(mode: str) -> None: """Set the active theme. Use ``"black"`` for pure-black background, ``"white"`` for pure-white background. Anything else is normalized.""" st.session_state["ui_theme_mode"] = mode if mode in THEME_MODES else "black" def inject_theme(mode: str | None = None): """Inject custom CSS for the chosen theme and hide Streamlit chrome. When ``mode`` is ``None`` we read the active mode from session state via :func:`get_theme_mode`. The base ``assets/theme.css`` is always included; theme-specific overrides are appended on top. """ if mode is None: mode = get_theme_mode() base_css_path = Path(__file__).parent / "assets" / "theme.css" overlay_css_path = Path(__file__).parent / "assets" / f"theme_{mode}.css" css = base_css_path.read_text() if base_css_path.exists() else "" if overlay_css_path.exists(): css += "\n\n" + overlay_css_path.read_text() st.markdown(f"", unsafe_allow_html=True) def hero_header(title, subtitle="", github_url="https://github.com/siddhant-rajhans/cortexlab"): """Render a futuristic hero header with gradient title.""" st.markdown(f"""
""", unsafe_allow_html=True) def glow_card(title, value, subtitle="", color="#06B6D4"): """Render a glowing metric card. Layout uses the ``cl-stat-card`` CSS class so background / border / text colors come from theme variables and flip automatically when the user switches between Black and White modes. Only the accent color (the big number) stays per-card. """ st.markdown( f"""{description}
' if description else "" ) st.markdown( f"""