Spaces:
Running
Running
File size: 6,728 Bytes
d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 c600f78 d360571 9ff9537 d360571 c600f78 d360571 c600f78 d360571 580f0af c600f78 d360571 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | """Toxic-Studio-Theme für 2B Studio (by EINswarm).
Liefert THEME (Gradio-Theme), CSS (aus web/studio.css) und HEAD (Preloads +
web/studio.js). Hell- und Dunkelmodus erhalten bewusst identische Werte,
damit ein heller Browser-Modus die Oberfläche nicht mehr verfälscht.
"""
from __future__ import annotations
from pathlib import Path
import gradio as gr
WEB_DIR = Path(__file__).resolve().parent / "web"
STATIC_DIR = Path(__file__).resolve().parents[1] / "static"
STATIC_URL = "/gradio_api/file=static"
ACID = "#d4af37"
ACID_HOVER = "#e2c25a"
ON_ACID = "#140f02"
INK = "#070707"
PANEL = "rgba(17, 17, 17, .86)"
FIELD = "rgba(6, 8, 5, .72)"
LINE = "rgba(212, 175, 55, .16)"
TEXT = "#f2eee6"
MUTED = "#c2b9a8"
_VARS: dict[str, str] = {
"body_background_fill": INK,
"body_text_color": TEXT,
"body_text_color_subdued": MUTED,
"background_fill_primary": "#0d0c0b",
"background_fill_secondary": "#12110e",
"border_color_primary": LINE,
"border_color_accent": "rgba(212, 175, 55, .55)",
"border_color_accent_subdued": "rgba(212, 175, 55, .3)",
"color_accent": ACID,
"color_accent_soft": "rgba(212, 175, 55, .14)",
"block_background_fill": PANEL,
"block_border_color": LINE,
"block_border_width": "1px",
"block_label_background_fill": "rgba(212, 175, 55, .1)",
"block_label_border_color": "rgba(212, 175, 55, .22)",
"block_label_text_color": "#efe2c4",
"block_title_text_color": TEXT,
"block_info_text_color": MUTED,
"block_shadow": "none",
"block_radius": "12px",
"panel_background_fill": PANEL,
"panel_border_color": LINE,
"input_background_fill": FIELD,
"input_background_fill_focus": "rgba(10, 14, 6, .9)",
"input_background_fill_hover": FIELD,
"input_border_color": "rgba(212, 175, 55, .2)",
"input_border_color_focus": ACID,
"input_border_color_hover": "rgba(212, 175, 55, .38)",
"input_placeholder_color": "#958c7c",
"input_shadow_focus": "0 0 0 3px rgba(212, 175, 55, .18)",
"input_radius": "8px",
"button_primary_background_fill": f"linear-gradient(135deg, #f0d68a 0%, {ACID} 45%, #b08a26 100%)",
"button_primary_background_fill_hover": f"linear-gradient(135deg, #f7e7b4 0%, {ACID_HOVER} 45%, {ACID} 100%)",
"button_primary_text_color": ON_ACID,
"button_primary_text_color_hover": ON_ACID,
"button_primary_border_color": ACID,
"button_primary_border_color_hover": "#f0d68a",
"button_primary_shadow": "0 0 24px -6px rgba(212, 175, 55, .55)",
"button_primary_shadow_hover": "0 0 34px -4px rgba(212, 175, 55, .75)",
"button_secondary_background_fill": "rgba(212, 175, 55, .06)",
"button_secondary_background_fill_hover": "rgba(212, 175, 55, .14)",
"button_secondary_text_color": "#f3e8cc",
"button_secondary_text_color_hover": "#ffffff",
"button_secondary_border_color": "rgba(212, 175, 55, .26)",
"button_secondary_border_color_hover": "rgba(212, 175, 55, .6)",
"button_cancel_background_fill": "rgba(255, 107, 138, .12)",
"button_cancel_background_fill_hover": "rgba(255, 107, 138, .22)",
"button_cancel_border_color": "rgba(255, 107, 138, .45)",
"button_cancel_text_color": "#ffd5de",
"button_large_radius": "6px",
"button_medium_radius": "6px",
"button_small_radius": "5px",
"checkbox_background_color": FIELD,
"checkbox_background_color_selected": ACID,
"checkbox_border_color": "rgba(212, 175, 55, .4)",
"checkbox_border_color_selected": ACID,
"checkbox_label_background_fill": "rgba(212, 175, 55, .05)",
"checkbox_label_background_fill_hover": "rgba(212, 175, 55, .1)",
"checkbox_label_background_fill_selected": "rgba(212, 175, 55, .16)",
"checkbox_label_border_color": "rgba(212, 175, 55, .18)",
"checkbox_label_border_color_selected": ACID,
"checkbox_label_text_color": "#f3e8cc",
"checkbox_label_text_color_selected": "#ffffff",
"slider_color": ACID,
"loader_color": ACID,
"link_text_color": ACID,
"link_text_color_hover": "#f0d68a",
"link_text_color_visited": "#c9a227",
"code_background_fill": "rgba(212, 175, 55, .08)",
"stat_background_fill": "rgba(212, 175, 55, .25)",
"table_even_background_fill": "#0e110b",
"table_odd_background_fill": "#12160e",
"table_border_color": LINE,
"error_background_fill": "rgba(255, 107, 138, .12)",
"error_border_color": "rgba(255, 107, 138, .5)",
"error_text_color": "#ffd5de",
"shadow_drop": "0 10px 30px -12px rgba(0, 0, 0, .8)",
"shadow_drop_lg": "0 20px 50px -18px rgba(0, 0, 0, .9)",
"container_radius": "12px",
}
def build_theme() -> gr.themes.Base:
theme = gr.themes.Base(
primary_hue=gr.themes.colors.amber,
secondary_hue=gr.themes.colors.amber,
neutral_hue=gr.themes.colors.stone,
# Font-Objekte statt Strings: Gradio vergleicht Themes beim launch() (Analytics) per Font.__eq__
font=[gr.themes.Font("Manrope"), gr.themes.Font("Segoe UI"), gr.themes.Font("sans-serif")],
font_mono=[gr.themes.Font("JetBrains Mono"), gr.themes.Font("monospace")],
radius_size=gr.themes.sizes.radius_md,
)
valid = set(vars(theme))
values = {k: v for k, v in _VARS.items() if k in valid}
values.update({f"{k}_dark": v for k, v in values.items() if f"{k}_dark" in valid})
return theme.set(**values)
def _read(name: str) -> str:
return (WEB_DIR / name).read_text(encoding="utf-8")
def build_css() -> str:
return _read("studio.css").replace("__STATIC__", STATIC_URL)
def _ver() -> str:
import hashlib
h = hashlib.sha1()
for name in ("daw.js", "daw.css"):
f = STATIC_DIR / "daw" / name
if f.exists():
h.update(f.read_bytes())
return h.hexdigest()[:10]
def build_head() -> str:
fonts = ("SairaStencilOne-400-latin", "ChakraPetch-600-latin", "Manrope-normal-latin")
preload = "".join(
f'<link rel="preload" href="{STATIC_URL}/fonts/{f}.woff2" as="font" type="font/woff2" crossorigin>'
for f in fonts
)
return (
'<meta name="theme-color" content="#070707">'
'<meta name="color-scheme" content="dark">'
'<meta name="description" content="2B Studio – KI-Musikstudio: generieren, hören, mastern. by EINswarm">'
f'<link rel="icon" type="image/svg+xml" href="{STATIC_URL}/img/favicon.svg">'
f"{preload}<script>{_read('studio.js')}</script>"
f"<script>{(STATIC_DIR / 'daw' / 'avatar-guard.js').read_text(encoding='utf-8')}</script>"
f'<link rel="stylesheet" href="{STATIC_URL}/daw/daw.css?v={_ver()}">'
f'<script defer src="{STATIC_URL}/daw/daw.js?v={_ver()}"></script>'
)
THEME = build_theme()
CSS = build_css()
HEAD = build_head()
|