diff --git a/web/src/App.css b/web/src/App.css
index c78a96e..ab37fad 100644
--- a/web/src/App.css
+++ b/web/src/App.css
@@ -1,4 +1,11 @@
-.ts-app {
+/* Wrapped in :where() so these three variable-defining rules carry ZERO
+ specificity. That's deliberate: a user-authored custom theme (injected
+ later as a plain `.ts-app { --accent: ... }` rule) has real specificity
+ and must always win here, regardless of which of these three blocks would
+ otherwise apply. Every other selector in this file is untouched, so the
+ normal cascade elsewhere (including .ts-app.ts-design-nova's non-variable
+ rules further down) still works exactly as before. */
+:where(.ts-app) {
--bg: #ffffff;
--bg-toolbar-1: #f5f6f8;
--bg-toolbar-2: #dfe2e6;
@@ -40,7 +47,7 @@
0 0 40px rgba(0, 0, 0, 0.5);
}
-.ts-app.ts-theme-dark {
+:where(.ts-app.ts-theme-dark) {
--bg: #1e1f22;
--bg-toolbar-1: #2b2d31;
--bg-toolbar-2: #232428;
@@ -67,7 +74,7 @@
/* Nova: alternate design, independent of the light/dark toggle (always dark). */
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");
-.ts-app.ts-design-nova {
+:where(.ts-app.ts-design-nova) {
--success: oklch(0.75 0.15 150);
--bg: oklch(0.17 0.014 258);
--bg-toolbar-1: oklch(0.205 0.015 258);
@@ -2419,6 +2426,74 @@
color: var(--text-muted);
}
+/* Custom-theme cards are a
(built-ins are a plain
) so the select
+ area and the edit/duplicate/export/delete row can sit side by side without
+ nesting a button inside a button. */
+.ts-design-theme-card-custom {
+ position: relative;
+}
+
+.ts-design-theme-card-select {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 0.4rem;
+ width: 100%;
+ padding: 0;
+ border: none;
+ background: transparent;
+ color: inherit;
+ cursor: pointer;
+ text-align: left;
+ font: inherit;
+}
+
+.ts-design-theme-swatch-custom {
+ background: conic-gradient(from 180deg, #7fb0e8, #ff8fab, #ffd166, #7fb0e8);
+}
+
+.ts-design-theme-card-actions {
+ display: flex;
+ gap: 0.3rem;
+ margin-top: 0.5rem;
+}
+
+.ts-design-theme-card-actions button {
+ flex: 1;
+ padding: 0.25rem 0;
+ border: 1px solid var(--border-soft);
+ border-radius: 3px;
+ background: var(--input-bg);
+ color: var(--text-muted);
+ cursor: pointer;
+ font-size: 12px;
+}
+
+.ts-design-theme-card-actions button:hover {
+ color: var(--text);
+ border-color: var(--accent);
+}
+
+.ts-design-custom-actions {
+ display: flex;
+ gap: 0.5rem;
+ margin-top: 0.75rem;
+}
+
+.ts-custom-theme-css {
+ width: 100%;
+ min-height: 220px;
+ font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace;
+ font-size: 12px;
+ padding: 0.5rem;
+ border: 1px solid var(--border);
+ border-radius: 4px;
+ background: var(--input-bg);
+ color: var(--input-text);
+ resize: vertical;
+ box-sizing: border-box;
+}
+
.ts-options-columns {
display: flex;
gap: 1rem;
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 078914c..3a4a27f 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -138,13 +138,56 @@ const NOISE_SUPPRESSION_KEY = "webspeak3:noise-suppression";
const ECHO_CANCELLATION_KEY = "webspeak3:echo-cancellation";
const VAD_HANGOVER_KEY = "webspeak3:vad-hangover";
const DESIGN_THEME_KEY = "webspeak3:design-theme";
+// The user's actual pick - "standard" | "nova" | "custom:". DESIGN_THEME_KEY above
+// keeps tracking just the resolved structural base, since a couple of early call sites
+// (e.g. the host-field default below) need that cheaply, before customThemes is loaded.
+const DESIGN_SELECTION_KEY = "webspeak3:design-selection";
+const CUSTOM_THEMES_KEY = "webspeak3:custom-themes";
type DesignTheme = "standard" | "nova";
+/** A user-authored theme package: a name, which built-in layout it behaves like
+ * (Standard's plain chrome vs Nova's collapsed menu/splash behavior), and raw CSS
+ * that gets injected while it's active - free-form, so it can restyle or even
+ * reflow the existing markup (e.g. via flex `order`, `display:none`, overlays). */
+type CustomTheme = {
+ id: string;
+ name: string;
+ baseTheme: DesignTheme;
+ css: string;
+};
+
function loadDesignTheme(): DesignTheme {
return localStorage.getItem(DESIGN_THEME_KEY) === "nova" ? "nova" : "standard";
}
+function loadCustomThemes(): CustomTheme[] {
+ try {
+ const raw = localStorage.getItem(CUSTOM_THEMES_KEY);
+ if (!raw) return [];
+ const parsed = JSON.parse(raw);
+ if (!Array.isArray(parsed)) return [];
+ return parsed.filter(
+ (v): v is CustomTheme =>
+ v &&
+ typeof v.id === "string" &&
+ typeof v.name === "string" &&
+ (v.baseTheme === "standard" || v.baseTheme === "nova") &&
+ typeof v.css === "string"
+ );
+ } catch {
+ return [];
+ }
+}
+
+function saveCustomThemes(list: CustomTheme[]) {
+ localStorage.setItem(CUSTOM_THEMES_KEY, JSON.stringify(list));
+}
+
+function loadDesignSelection(): string {
+ return localStorage.getItem(DESIGN_SELECTION_KEY) ?? loadDesignTheme();
+}
+
function loadBoolPref(key: string, fallback: boolean): boolean {
const raw = localStorage.getItem(key);
return raw === null ? fallback : raw === "1";
@@ -3571,34 +3614,185 @@ function AnwendungPanel() {
);
}
+type CustomThemeDraft = { id: string | null; name: string; baseTheme: DesignTheme; css: string };
+
function DesignPanel({
- designTheme,
- onDesignThemeChange,
+ designSelection,
+ onSelectionChange,
+ customThemes,
+ onSaveCustomTheme,
+ onDeleteCustomTheme,
}: {
- designTheme: DesignTheme;
- onDesignThemeChange: (next: DesignTheme) => void;
+ designSelection: string;
+ onSelectionChange: (next: string) => void;
+ customThemes: CustomTheme[];
+ onSaveCustomTheme: (theme: CustomTheme) => void;
+ onDeleteCustomTheme: (id: string) => void;
}) {
const t = useT();
- const themes: { id: DesignTheme; name: string; desc: string }[] = [
+ const [editing, setEditing] = useState(null);
+ const importInputRef = useRef(null);
+
+ const builtins: { id: DesignTheme; name: string; desc: string }[] = [
{ id: "standard", name: t("design.theme.standard"), desc: t("design.theme.standard.desc") },
{ id: "nova", name: t("design.theme.nova"), desc: t("design.theme.nova.desc") },
];
+
+ const handleSaveEditing = () => {
+ if (!editing || !editing.name.trim()) return;
+ const id = editing.id ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
+ onSaveCustomTheme({ id, name: editing.name.trim(), baseTheme: editing.baseTheme, css: editing.css });
+ onSelectionChange(`custom:${id}`);
+ setEditing(null);
+ };
+
+ const handleExport = (theme: CustomTheme) => {
+ const blob = new Blob(
+ [JSON.stringify({ name: theme.name, baseTheme: theme.baseTheme, css: theme.css }, null, 2)],
+ { type: "application/json" }
+ );
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${theme.name.replace(/[^a-z0-9-_]+/gi, "_") || "theme"}.webspeak3theme.json`;
+ a.click();
+ URL.revokeObjectURL(url);
+ };
+
+ const handleImportSelected = async (e: React.ChangeEvent) => {
+ const file = e.target.files?.[0];
+ e.target.value = "";
+ if (!file) return;
+ try {
+ const parsed = JSON.parse(await file.text());
+ if (
+ !parsed ||
+ typeof parsed.name !== "string" ||
+ (parsed.baseTheme !== "standard" && parsed.baseTheme !== "nova") ||
+ typeof parsed.css !== "string"
+ ) {
+ window.alert(t("design.custom.importError"));
+ return;
+ }
+ const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
+ onSaveCustomTheme({ id, name: parsed.name, baseTheme: parsed.baseTheme, css: parsed.css });
+ onSelectionChange(`custom:${id}`);
+ } catch {
+ window.alert(t("design.custom.importError"));
+ }
+ };
+
+ if (editing) {
+ return (
+ <>
+ {editing.id ? t("design.custom.editTitle") : t("design.custom.newTitle")}
+
+ {t("design.custom.name")}
+ setEditing({ ...editing, name: e.target.value })} autoFocus />
+
+
+ {t("design.custom.base")}
+ setEditing({ ...editing, baseTheme: e.target.value as DesignTheme })}
+ >
+ {t("design.theme.standard")}
+ {t("design.theme.nova")}
+
+
+
+ {t("design.custom.css")}
+
+ {t("design.custom.hint")}
+
+ setEditing(null)}>{t("connect.cancel")}
+
+ {t("design.custom.save")}
+
+
+ >
+ );
+ }
+
return (
<>
{t("options.section.design")}
{t("design.subtitle")}
- {themes.map((th) => (
+ {builtins.map((th) => (
onDesignThemeChange(th.id)}
+ className={`ts-design-theme-card${th.id === designSelection ? " ts-design-theme-card-active" : ""}`}
+ onClick={() => onSelectionChange(th.id)}
>
{th.name}
{th.desc}
))}
+ {customThemes.map((theme) => (
+
+
onSelectionChange(`custom:${theme.id}`)}>
+
+ {theme.name}
+
+ {theme.baseTheme === "nova" ? t("design.theme.nova") : t("design.theme.standard")}
+
+
+
+ setEditing({ id: theme.id, name: theme.name, baseTheme: theme.baseTheme, css: theme.css })}
+ title={t("design.custom.edit")}
+ >
+ ✎
+
+
+ setEditing({ id: null, name: t("design.custom.copyOf", { name: theme.name }), baseTheme: theme.baseTheme, css: theme.css })
+ }
+ title={t("design.custom.duplicate")}
+ >
+ ⧉
+
+ handleExport(theme)} title={t("design.custom.export")}>
+ ⭳
+
+ {
+ if (window.confirm(t("design.custom.deleteConfirm"))) onDeleteCustomTheme(theme.id);
+ }}
+ title={t("design.custom.delete")}
+ >
+ 🗑
+
+
+
+ ))}
+
+
+ setEditing({ id: null, name: "", baseTheme: "standard", css: "" })}>
+ {t("design.custom.new")}
+
+ importInputRef.current?.click()}>{t("design.custom.import")}
+
>
);
@@ -3871,15 +4065,21 @@ function OptionsDialog({
onSectionChange,
onClose,
audio,
- designTheme,
- onDesignThemeChange,
+ designSelection,
+ onDesignSelectionChange,
+ customThemes,
+ onSaveCustomTheme,
+ onDeleteCustomTheme,
}: {
section: string;
onSectionChange: (id: string) => void;
onClose: () => void;
audio: AudioSettings;
- designTheme: DesignTheme;
- onDesignThemeChange: (next: DesignTheme) => void;
+ designSelection: string;
+ onDesignSelectionChange: (next: string) => void;
+ customThemes: CustomTheme[];
+ onSaveCustomTheme: (theme: CustomTheme) => void;
+ onDeleteCustomTheme: (id: string) => void;
}) {
const t = useT();
const active = OPTIONS_SECTIONS.find((s) => s.id === section) ?? OPTIONS_SECTIONS[0];
@@ -3916,7 +4116,13 @@ function OptionsDialog({
) : active.id === "sounds" ? (
) : active.id === "design" ? (
-
+
) : active.id === "nachrichten" ? (
) : (
@@ -4284,11 +4490,55 @@ function AppInner() {
const [theme, setTheme] = useState<"light" | "dark">(() =>
window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"
);
- const [designTheme, setDesignTheme] = useState(() => loadDesignTheme());
- const handleDesignThemeChange = (next: DesignTheme) => {
- setDesignTheme(next);
- localStorage.setItem(DESIGN_THEME_KEY, next);
+ const [customThemes, setCustomThemes] = useState(() => loadCustomThemes());
+ const [designSelection, setDesignSelection] = useState(() => loadDesignSelection());
+ const activeCustomTheme = designSelection.startsWith("custom:")
+ ? customThemes.find((th) => `custom:${th.id}` === designSelection) ?? null
+ : null;
+ // Structural base - everywhere else in the app that branches on "nova" behavior
+ // (splash, hamburger menu, ...) keeps working unchanged, whether that behavior
+ // came from picking Nova directly or from a custom theme built on top of it.
+ const designTheme: DesignTheme = activeCustomTheme ? activeCustomTheme.baseTheme : designSelection === "nova" ? "nova" : "standard";
+ const handleDesignSelectionChange = (next: string) => {
+ setDesignSelection(next);
+ localStorage.setItem(DESIGN_SELECTION_KEY, next);
+ const base = next.startsWith("custom:")
+ ? customThemes.find((th) => `custom:${th.id}` === next)?.baseTheme ?? "standard"
+ : next === "nova"
+ ? "nova"
+ : "standard";
+ localStorage.setItem(DESIGN_THEME_KEY, base);
};
+ const handleSaveCustomTheme = (nextTheme: CustomTheme) => {
+ setCustomThemes((prev) => {
+ const idx = prev.findIndex((th) => th.id === nextTheme.id);
+ const next = idx === -1 ? [...prev, nextTheme] : prev.map((th, i) => (i === idx ? nextTheme : th));
+ saveCustomThemes(next);
+ return next;
+ });
+ };
+ const handleDeleteCustomTheme = (id: string) => {
+ setCustomThemes((prev) => {
+ const next = prev.filter((th) => th.id !== id);
+ saveCustomThemes(next);
+ return next;
+ });
+ if (designSelection === `custom:${id}`) handleDesignSelectionChange("standard");
+ };
+ // Custom themes ship as free-form CSS - inject/replace it in a dedicated