farbschema angepasst

This commit is contained in:
Bernd Reuther committed 2026-10-05 18:40:31 +02:00
1 parent 440d1004b6
commit 1a8e99ef82
2 files changed
+50 -150

No files matched your search

+19 -72
View File
@@ -46,13 +46,13 @@ DEFAULT_SETTINGS = {
} }
BASE_THEME = { BASE_THEME = {
"background": "#111111", "surface": "#181818", "text": "#eeeeee", "background": "#111111", "surface": "#181818", "surface_dark": "#0b0b0b", "text": "#eeeeee",
"text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33", "text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33",
"success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f", "success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f",
} }
BASE_COLOR_LABELS = { BASE_COLOR_LABELS = {
"background": "Hintergrund", "surface": "Flächen", "text": "Text", "background": "Hintergrund", "surface_dark": "Dunkle Fläche", "surface": "Flächen", "text": "Text",
"text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe", "text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe",
"success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr", "success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr",
} }
@@ -72,81 +72,28 @@ def _mix(a, b, amount):
def _lighten(value, amount): return _mix(value, "#ffffff", amount) def _lighten(value, amount): return _mix(value, "#ffffff", amount)
def _darken(value, amount): return _mix(value, "#000000", amount) def _darken(value, amount): return _mix(value, "#000000", amount)
def _luminance(value):
rgb = _hex_rgb(value)
if rgb is None:
return 0.0
channels = [c / 255.0 for c in rgb]
linear = [c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 for c in channels]
return 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2]
def _contrast_ratio(a, b):
return (max(_luminance(a), _luminance(b)) + 0.05) / (min(_luminance(a), _luminance(b)) + 0.05)
def _contrast_text(background):
return "#ffffff" if _contrast_ratio("#ffffff", background) >= _contrast_ratio("#000000", background) else "#000000"
def _ensure_contrast(foreground, background, minimum=4.5):
if _contrast_ratio(foreground, background) >= minimum:
return foreground
target = "#ffffff" if _contrast_ratio("#ffffff", background) > _contrast_ratio("#000000", background) else "#000000"
lo, hi = 0.0, 1.0
for _ in range(12):
mid = (lo + hi) / 2
candidate = _mix(foreground, target, mid)
if _contrast_ratio(candidate, background) >= minimum:
hi = mid
else:
lo = mid
return _mix(foreground, target, hi)
def _surface_step(value, background, amount):
return _lighten(value, amount) if _luminance(background) < 0.5 else _darken(value, amount)
def derive_theme(base): def derive_theme(base):
c = dict(BASE_THEME) c = dict(BASE_THEME)
if isinstance(base, dict): if isinstance(base, dict):
for key in BASE_THEME: for key in BASE_THEME:
value = base.get(key) value = base.get(key)
if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): c[key] = value.strip()
c[key] = value.strip() bg, surface, surface_dark = c["background"], c["surface"], c["surface_dark"]
text, secondary = c["text"], c["text_secondary"]
bg = c["background"] primary, accent = c["primary"], c["accent"]
surface = c["surface"] success, warning, danger = c["success"], c["warning"], c["danger"]
# User-selected text colors are kept as close as possible to the chosen
# color, but are automatically corrected when they would become unreadable.
text = _ensure_contrast(c["text"], bg, 4.5)
secondary = _ensure_contrast(c["text_secondary"], bg, 4.5)
surface_alt = _surface_step(surface, bg, 0.14)
control = _surface_step(surface, bg, 0.10)
control_hover = _surface_step(surface, bg, 0.20)
primary = c["primary"]
accent = c["accent"]
primary_hover = _surface_step(primary, bg, 0.14)
success = c["success"]
warning = c["warning"]
danger = c["danger"]
return { return {
"background": bg, "surface": surface, "surface_alt": surface_alt, "surface_dark": _darken(bg,.22), "background": bg, "surface": surface, "surface_alt": _lighten(surface,.12), "surface_dark": surface_dark,
"text": text, "text_secondary": secondary, "text": text, "text_secondary": secondary, "text_muted": _mix(secondary,bg,.35), "text_faint": _mix(secondary,bg,.58),
"text_muted": _ensure_contrast(_mix(secondary,bg,.35), bg, 3.0), "border": _lighten(surface,.28), "border_subtle": _lighten(surface,.16), "control": _lighten(surface,.12), "control_hover": _lighten(surface,.24),
"text_faint": _ensure_contrast(_mix(secondary,bg,.58), bg, 2.2), "primary": primary, "primary_hover": _lighten(primary,.16), "accent": accent,
"border": _surface_step(surface,bg,.28), "border_subtle": _surface_step(surface,bg,.16), "success": _darken(success,.42), "success_text": _lighten(success,.68), "warning": _darken(warning,.48),
"control": control, "control_hover": control_hover, "danger": danger, "danger_soft": _darken(danger,.58), "danger_soft_hover": _darken(danger,.42),
"primary": primary, "primary_hover": primary_hover, "primary_text": _contrast_text(primary), "error": _darken(danger,.62), "error_text": _lighten(danger,.70), "recording": _darken(danger,.08), "recording_border": _darken(danger,.52),
"accent": accent, "selection": "rgba(80,150,255,.16)", "shadow": "#000000", "scroll_thumb": _mix(secondary,bg,.35),
"success": success, "success_text": _contrast_text(success), "scroll_thumb_hover": _mix(secondary,bg,.18), "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84),
"warning": warning, "warning_text": _contrast_text(warning), "table_header": _lighten(surface,.08), "table_text": text, "footer": _mix(secondary,bg,.50), "white": "#ffffff",
"danger": danger, "danger_soft": _mix(danger,bg,.82), "danger_soft_hover": _mix(danger,bg,.70), "surface_modal": _lighten(surface,.05), "overlay": "rgba(0,0,0,.78)",
"error": _mix(danger,bg,.72), "error_text": _contrast_text(_mix(danger,bg,.72)),
"recording": danger, "recording_border": _mix(danger,bg,.55), "recording_text": _contrast_text(danger),
"selection": _mix(primary,bg,.84), "shadow": "#000000",
"scroll_thumb": _mix(secondary,bg,.35), "scroll_thumb_hover": _mix(secondary,bg,.18),
"scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84),
"table_header": _surface_step(surface,bg,.08), "table_text": _ensure_contrast(text,surface,4.5),
"footer": _ensure_contrast(_mix(secondary,bg,.50), bg, 2.2), "white": "#ffffff",
"surface_modal": _surface_step(surface,bg,.05), "overlay": "rgba(0,0,0,.78)",
} }
DEFAULT_THEME = derive_theme(BASE_THEME) DEFAULT_THEME = derive_theme(BASE_THEME)
@@ -2033,7 +1980,7 @@ a { color:var(--color-text-secondary); }
.color-field input[type=color] { width:48px; height:40px; padding:3px; background:var(--color-control); border:1px solid var(--color-control-hover); border-radius:5px; cursor:pointer; } .color-field input[type=color] { width:48px; height:40px; padding:3px; background:var(--color-control); border:1px solid var(--color-control-hover); border-radius:5px; cursor:pointer; }
.theme-intro { margin:-4px 0 16px; color:var(--color-text-muted); font-size:14px; line-height:1.45; } .theme-intro { margin:-4px 0 16px; color:var(--color-text-muted); font-size:14px; line-height:1.45; }
.actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:20px; } .actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:20px; }
button { border:0; border-radius:5px; padding:10px 16px; background:var(--color-primary); color:var(--color-primary-text); font-size:15px; cursor:pointer; } button { border:0; border-radius:5px; padding:10px 16px; background:var(--color-primary); color:var(--color-white); font-size:15px; cursor:pointer; }
button:hover { background:var(--color-primary-hover); } button:hover { background:var(--color-primary-hover); }
.note { color:var(--color-text-muted); font-size:13px; margin-top:8px; } .note { color:var(--color-text-muted); font-size:13px; margin-top:8px; }
.message { padding:10px 12px; border-radius:6px; margin-bottom:16px; background:var(--color-success); color:var(--color-success-text); } .message { padding:10px 12px; border-radius:6px; margin-bottom:16px; background:var(--color-success); color:var(--color-success-text); }
+31 -78
View File
@@ -6,6 +6,7 @@ import json
import re import re
import time import time
from datetime import datetime from datetime import datetime
from urllib.parse import quote
from pathlib import Path from pathlib import Path
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
@@ -76,13 +77,13 @@ DEFAULT_SETTINGS = {
} }
BASE_THEME = { BASE_THEME = {
"background": "#111111", "surface": "#181818", "text": "#eeeeee", "background": "#111111", "surface": "#181818", "surface_dark": "#0b0b0b", "text": "#eeeeee",
"text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33", "text_secondary": "#cccccc", "primary": "#1769aa", "accent": "#ffcc33",
"success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f", "success": "#2e7d32", "warning": "#ed6c02", "danger": "#d32f2f",
} }
BASE_COLOR_LABELS = { BASE_COLOR_LABELS = {
"background": "Hintergrund", "surface": "Flächen", "text": "Text", "background": "Hintergrund", "surface_dark": "Dunkle Fläche", "surface": "Flächen", "text": "Text",
"text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe", "text_secondary": "Sekundärtext", "primary": "Primärfarbe", "accent": "Akzentfarbe",
"success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr", "success": "Erfolg", "warning": "Warnung", "danger": "Fehler / Gefahr",
} }
@@ -102,81 +103,28 @@ def _mix(a, b, amount):
def _lighten(value, amount): return _mix(value, "#ffffff", amount) def _lighten(value, amount): return _mix(value, "#ffffff", amount)
def _darken(value, amount): return _mix(value, "#000000", amount) def _darken(value, amount): return _mix(value, "#000000", amount)
def _luminance(value):
rgb = _hex_rgb(value)
if rgb is None:
return 0.0
channels = [c / 255.0 for c in rgb]
linear = [c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 for c in channels]
return 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2]
def _contrast_ratio(a, b):
return (max(_luminance(a), _luminance(b)) + 0.05) / (min(_luminance(a), _luminance(b)) + 0.05)
def _contrast_text(background):
return "#ffffff" if _contrast_ratio("#ffffff", background) >= _contrast_ratio("#000000", background) else "#000000"
def _ensure_contrast(foreground, background, minimum=4.5):
if _contrast_ratio(foreground, background) >= minimum:
return foreground
target = "#ffffff" if _contrast_ratio("#ffffff", background) > _contrast_ratio("#000000", background) else "#000000"
lo, hi = 0.0, 1.0
for _ in range(12):
mid = (lo + hi) / 2
candidate = _mix(foreground, target, mid)
if _contrast_ratio(candidate, background) >= minimum:
hi = mid
else:
lo = mid
return _mix(foreground, target, hi)
def _surface_step(value, background, amount):
return _lighten(value, amount) if _luminance(background) < 0.5 else _darken(value, amount)
def derive_theme(base): def derive_theme(base):
c = dict(BASE_THEME) c = dict(BASE_THEME)
if isinstance(base, dict): if isinstance(base, dict):
for key in BASE_THEME: for key in BASE_THEME:
value = base.get(key) value = base.get(key)
if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): if isinstance(value, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", value.strip()): c[key] = value.strip()
c[key] = value.strip() bg, surface, surface_dark = c["background"], c["surface"], c["surface_dark"]
text, secondary = c["text"], c["text_secondary"]
bg = c["background"] primary, accent = c["primary"], c["accent"]
surface = c["surface"] success, warning, danger = c["success"], c["warning"], c["danger"]
# User-selected text colors are kept as close as possible to the chosen
# color, but are automatically corrected when they would become unreadable.
text = _ensure_contrast(c["text"], bg, 4.5)
secondary = _ensure_contrast(c["text_secondary"], bg, 4.5)
surface_alt = _surface_step(surface, bg, 0.14)
control = _surface_step(surface, bg, 0.10)
control_hover = _surface_step(surface, bg, 0.20)
primary = c["primary"]
accent = c["accent"]
primary_hover = _surface_step(primary, bg, 0.14)
success = c["success"]
warning = c["warning"]
danger = c["danger"]
return { return {
"background": bg, "surface": surface, "surface_alt": surface_alt, "surface_dark": _darken(bg,.22), "background": bg, "surface": surface, "surface_alt": _lighten(surface,.12), "surface_dark": surface_dark,
"text": text, "text_secondary": secondary, "text": text, "text_secondary": secondary, "text_muted": _mix(secondary,bg,.35), "text_faint": _mix(secondary,bg,.58),
"text_muted": _ensure_contrast(_mix(secondary,bg,.35), bg, 3.0), "border": _lighten(surface,.28), "border_subtle": _lighten(surface,.16), "control": _lighten(surface,.12), "control_hover": _lighten(surface,.24),
"text_faint": _ensure_contrast(_mix(secondary,bg,.58), bg, 2.2), "primary": primary, "primary_hover": _lighten(primary,.16), "accent": accent,
"border": _surface_step(surface,bg,.28), "border_subtle": _surface_step(surface,bg,.16), "success": _darken(success,.42), "success_text": _lighten(success,.68), "warning": _darken(warning,.48),
"control": control, "control_hover": control_hover, "danger": danger, "danger_soft": _darken(danger,.58), "danger_soft_hover": _darken(danger,.42),
"primary": primary, "primary_hover": primary_hover, "primary_text": _contrast_text(primary), "error": _darken(danger,.62), "error_text": _lighten(danger,.70), "recording": _darken(danger,.08), "recording_border": _darken(danger,.52),
"accent": accent, "selection": "rgba(80,150,255,.16)", "shadow": "#000000", "scroll_thumb": _mix(secondary,bg,.35),
"success": success, "success_text": _contrast_text(success), "scroll_thumb_hover": _mix(secondary,bg,.18), "scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84),
"warning": warning, "warning_text": _contrast_text(warning), "table_header": _lighten(surface,.08), "table_text": text, "footer": _mix(secondary,bg,.50), "white": "#ffffff",
"danger": danger, "danger_soft": _mix(danger,bg,.82), "danger_soft_hover": _mix(danger,bg,.70), "surface_modal": _lighten(surface,.05), "overlay": "rgba(0,0,0,.78)",
"error": _mix(danger,bg,.72), "error_text": _contrast_text(_mix(danger,bg,.72)),
"recording": danger, "recording_border": _mix(danger,bg,.55), "recording_text": _contrast_text(danger),
"selection": _mix(primary,bg,.84), "shadow": "#000000",
"scroll_thumb": _mix(secondary,bg,.35), "scroll_thumb_hover": _mix(secondary,bg,.18),
"scroll_thumb_active": secondary, "live_surface": _mix(danger,bg,.84),
"table_header": _surface_step(surface,bg,.08), "table_text": _ensure_contrast(text,surface,4.5),
"footer": _ensure_contrast(_mix(secondary,bg,.50), bg, 2.2), "white": "#ffffff",
"surface_modal": _surface_step(surface,bg,.05), "overlay": "rgba(0,0,0,.78)",
} }
DEFAULT_THEME = derive_theme(BASE_THEME) DEFAULT_THEME = derive_theme(BASE_THEME)
@@ -770,9 +718,7 @@ HTML = """
.site-header { display:flex; align-items:center; gap:18px; margin-bottom:24px; } .site-header { display:flex; align-items:center; gap:18px; margin-bottom:24px; }
.site-logo { max-width:140px; max-height:48px; object-fit:contain; display:block; flex:0 0 auto; } .site-logo { max-width:140px; max-height:48px; object-fit:contain; display:block; flex:0 0 auto; }
.site-header h1 { margin:0; flex:1; } .site-header h1 { margin:0; }
.header-link { color:var(--color-primary); text-decoration:none; font-weight:700; padding:8px 12px; border:1px solid var(--color-border); border-radius:6px; }
.header-link:hover { background:var(--color-control-hover); color:var(--color-text); }
body { body {
margin: 0; margin: 0;
@@ -802,7 +748,7 @@ h1 {
.status.recording { .status.recording {
background: var(--color-danger); background: var(--color-danger);
color:var(--color-recording-text); color:var(--color-white);
} }
.status.idle { .status.idle {
@@ -812,7 +758,7 @@ h1 {
.status.error { .status.error {
background: var(--color-warning); background: var(--color-warning);
color:var(--color-warning-text); color:var(--color-white);
} }
.recording { .recording {
@@ -1021,7 +967,6 @@ a.button:hover {
<div class="site-header"> <div class="site-header">
{% if logo_url %}<img class="site-logo" src="{{ logo_url }}" alt="{{ site_name }}">{% endif %} {% if logo_url %}<img class="site-logo" src="{{ logo_url }}" alt="{{ site_name }}">{% endif %}
<h1>{{ page_heading }}</h1> <h1>{{ page_heading }}</h1>
{% if editor_url %}<a class="header-link" href="{{ editor_url }}">✂ Editor</a>{% endif %}
</div> </div>
<div class="subtitle">{{ site_subtitle }}</div> <div class="subtitle">{{ site_subtitle }}</div>
@@ -1143,7 +1088,10 @@ a.button:hover {
</audio> </audio>
</td> </td>
<td> <td class="actions">
{% if item.edit_url %}
<a class="button" href="{{ item.edit_url }}">✂ Bearbeiten</a>
{% endif %}
<a class="button" <a class="button"
href="/finished/{{ item.filename }}" href="/finished/{{ item.filename }}"
download> download>
@@ -1363,6 +1311,7 @@ def render_index():
global normalizing_filename global normalizing_filename
files = [] files = []
editor_base_url = load_settings().get("editor_url", "")
FINISHED_DIR.mkdir(parents=True, exist_ok=True) FINISHED_DIR.mkdir(parents=True, exist_ok=True)
@@ -1385,6 +1334,10 @@ def render_index():
for item in files: for item in files:
item["sort_ts"] = item["sort_date"] item["sort_ts"] = item["sort_date"]
item["edit_url"] = (
f"{editor_base_url.rstrip('/')}/edit/{quote(item['filename'])}"
if editor_base_url else ""
)
files.sort(key=lambda item: item["sort_date"], reverse=True) files.sort(key=lambda item: item["sort_date"], reverse=True)
artists = sorted({item["artist"] for item in files if item["artist"]}) artists = sorted({item["artist"] for item in files if item["artist"]})