"""Arayüz teması: TestAjanı ile aynı görsel dil (koyu lacivert zemin, çerçeveli kartlar, indigo vurgu, üst gezinme).
Renkler hem Streamlit temasına (bileşenler) hem de CSS'e (özel parçalar) verilir. Açık ve koyu iki palet vardır.
"""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parent
FONT = "Plus Jakarta Sans"
FONT_URL = "https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap"
MONO = "JetBrains Mono"
MONO_URL = "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap"
PALETTE = {
"dark": {
"bg": "#12161f", "header": "#161b26", "surface": "#1a1f2b", "surface2": "#202636", "input": "#151a24",
"line": "#2d3445", "line_soft": "#252b3a", "ink": "#e7e9f0", "ink2": "#b6bccb", "muted": "#8a92a6",
"acc": "#7d8ff0", "acc_ink": "#ffffff", "acc_soft": "#262d52", "acc_text": "#a9b5ff",
"ok": "#4cc59f", "ok_bg": "#173a31", "warn": "#f0b429", "warn_bg": "#3a2f14", "bad": "#f47067",
"bad_bg": "#3d1f22", "code_bg": "#1e1e1e",
},
"light": {
"bg": "#f4f5f9", "header": "#ffffff", "surface": "#ffffff", "surface2": "#f7f8fc", "input": "#ffffff",
"line": "#e1e4ee", "line_soft": "#eceef5", "ink": "#151925", "ink2": "#3d4456", "muted": "#687086",
"acc": "#5b6ee8", "acc_ink": "#ffffff", "acc_soft": "#e9ecfd", "acc_text": "#4152c9",
"ok": "#178a65", "ok_bg": "#def4ec", "warn": "#9a6700", "warn_bg": "#fdf1d6", "bad": "#c4362b",
"bad_bg": "#fde8e6", "code_bg": "#f6f7fb",
},
}
def palette(theme: str) -> dict:
return PALETTE["dark" if theme == "dark" else "light"]
def streamlit_theme(theme: str) -> dict:
"""st._config.set_option ile verilecek tema ayarları."""
P = palette(theme)
return {
"base": "dark" if theme == "dark" else "light",
"primaryColor": P["acc"], "backgroundColor": P["bg"], "secondaryBackgroundColor": P["surface2"],
"textColor": P["ink"], "borderColor": P["line"], "linkColor": P["acc_text"],
"codeBackgroundColor": P["code_bg"], "dataframeHeaderBackgroundColor": P["surface2"],
"dataframeBorderColor": P["line"], "showWidgetBorder": True, "baseRadius": "10px", "buttonRadius": "9px",
"font": f"{FONT}:{FONT_URL}", "codeFont": f"{MONO}:{MONO_URL}", "headingFontWeights": [700, 650],
"greenColor": P["ok"], "redColor": P["bad"], "orangeColor": P["warn"], "violetColor": P["acc"],
"blueColor": P["acc"],
"chartCategoricalColors": ["#7d8ff0", "#4cc59f", "#f0b429", "#f47067", "#a78bfa", "#38bdf8", "#94a3b8"]
if theme == "dark" else ["#5b6ee8", "#178a65", "#d08f00", "#c4362b", "#8b5cf6", "#0ea5e9", "#64748b"],
}
def logo_svg(theme: str, small: bool = False) -> str:
"""Marka: indigo kare içinde tablo simgesi + 'Tablo2SQL' yazısı (TestAjanı'ndaki gibi)."""
P = palette(theme)
mark = (f""
""
"")
if small:
return f""
return (f"")
def write_logos(out_dir: Path, theme: str) -> tuple[Path, Path]:
out_dir.mkdir(parents=True, exist_ok=True)
big, small = out_dir / f"logo_{theme}.svg", out_dir / f"logo_{theme}_ikon.svg"
for p, s in ((big, logo_svg(theme)), (small, logo_svg(theme, small=True))):
if not p.exists() or p.read_text(encoding="utf-8") != s:
p.write_text(s, encoding="utf-8")
return big, small
def css(theme: str, lang: str) -> str:
P = palette(theme)
dark = theme == "dark"
return f"""
"""