feat(ui): Styleguide-Tokens und Theme-Auswahl, Playground mit festen Einstellungen und Eingabe (#1075, #1089, #1098)
- tokens.css und theme.js des Styleguides eingebettet (/ui/stil/), app.css ohne eigene Farbwerte; Darstellung System, Dunkel, Hell in der Fußzeile. - Wortmarke nutzt --accent-strong, im hellen Theme dunkler (Kontrast). - Playground: Einstellungen oben, Eingabe unten, nur der Verlauf scrollt. - Test für die Einbindung und das Layout; im Browser lokal geprüft. Klicktests browser2stil.1 bis .3 angelegt. - components.css bewusst nicht übernommen (andere Klassennamen). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
40
crates/nexus-api/assets/stil/theme.js
Normal file
40
crates/nexus-api/assets/stil/theme.js
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Theme-Auswahl nach STYLEGUIDE.md (Abschnitt 4): "system" | "dark" | "light".
|
||||
* "system" entfernt data-theme, dann entscheidet prefers-color-scheme (siehe tokens.css).
|
||||
*
|
||||
* Gegen Aufblitzen beim Laden früh im <head> einbinden (ohne type="module"):
|
||||
* <script src="theme.js"></script>
|
||||
* Danach per Schalter: styleguideTheme.set("dark").
|
||||
*/
|
||||
(function () {
|
||||
var KEY = "styleguide-theme";
|
||||
var VALID = ["system", "dark", "light"];
|
||||
|
||||
function read() {
|
||||
try {
|
||||
var v = localStorage.getItem(KEY);
|
||||
return VALID.indexOf(v) >= 0 ? v : "system";
|
||||
} catch (e) {
|
||||
return "system";
|
||||
}
|
||||
}
|
||||
|
||||
function apply(value) {
|
||||
var root = document.documentElement;
|
||||
if (value === "dark" || value === "light") root.setAttribute("data-theme", value);
|
||||
else root.removeAttribute("data-theme");
|
||||
}
|
||||
|
||||
function set(value) {
|
||||
if (VALID.indexOf(value) < 0) value = "system";
|
||||
try {
|
||||
if (value === "system") localStorage.removeItem(KEY);
|
||||
else localStorage.setItem(KEY, value);
|
||||
} catch (e) {}
|
||||
apply(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
apply(read());
|
||||
window.styleguideTheme = { get: read, set: set };
|
||||
})();
|
||||
206
crates/nexus-api/assets/stil/tokens.css
Normal file
206
crates/nexus-api/assets/stil/tokens.css
Normal file
@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Design-Tokens des Styleguides (siehe STYLEGUIDE.md, Version 1).
|
||||
* Dunkel ist der Fallback, Hell gilt bei entsprechender Systemeinstellung.
|
||||
* Eine bewusste Auswahl lässt sich über data-theme="dark" | "light" am <html>-Element erzwingen.
|
||||
* Quelle der Werte ist STYLEGUIDE.md; beide Dateien gemeinsam ändern.
|
||||
*/
|
||||
|
||||
/* Dunkel (Fallback) */
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
|
||||
--bg: #0f1115;
|
||||
--surface: #181b21;
|
||||
--surface-2: #222630;
|
||||
--text: #eceff4;
|
||||
--muted: #9099a8;
|
||||
--border: #2b303a;
|
||||
--border-field: #6b7585;
|
||||
--accent: #ff9b45;
|
||||
--accent-strong: #ff9b45;
|
||||
--accent-soft: rgba(255, 155, 69, .14);
|
||||
--accent-text: #1a1005;
|
||||
--ok: #6fd18a;
|
||||
--warn: #ffcf5c;
|
||||
--danger: #ff7b72;
|
||||
--info: #4fc3dc;
|
||||
--on-ok: #06180d;
|
||||
--on-warn: #1a1405;
|
||||
--on-danger: #1a0805;
|
||||
--cat-1: #b69cff;
|
||||
--cat-2: #7aa7ff;
|
||||
--cat-3: #ff7ac0;
|
||||
--bg-glow: rgba(255, 155, 69, .10);
|
||||
--shadow: 0 6px 24px rgba(0, 0, 0, .35);
|
||||
}
|
||||
|
||||
/* Hell bei Systemeinstellung, sofern nicht bewusst Dunkel gewählt wurde */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not([data-theme="dark"]) {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #f6f3ef;
|
||||
--surface: #ffffff;
|
||||
--surface-2: #f0ebe4;
|
||||
--text: #1d1a17;
|
||||
--muted: #6b645c;
|
||||
--border: #e2dbd2;
|
||||
--border-field: #8a8378;
|
||||
--accent: #f08a2c;
|
||||
--accent-strong: #a8530a;
|
||||
--accent-soft: rgba(240, 138, 44, .14);
|
||||
--accent-text: #ffffff;
|
||||
--ok: #217346;
|
||||
--warn: #8a6100;
|
||||
--danger: #c0392b;
|
||||
--info: #0b7285;
|
||||
--on-ok: #ffffff;
|
||||
--on-warn: #ffffff;
|
||||
--on-danger: #ffffff;
|
||||
--cat-1: #6941c6;
|
||||
--cat-2: #175cd3;
|
||||
--cat-3: #c11574;
|
||||
--bg-glow: rgba(255, 155, 69, .16);
|
||||
--shadow: 0 6px 20px rgba(60, 40, 20, .10);
|
||||
}
|
||||
}
|
||||
|
||||
/* Hell bei bewusster Auswahl */
|
||||
:root[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #f6f3ef;
|
||||
--surface: #ffffff;
|
||||
--surface-2: #f0ebe4;
|
||||
--text: #1d1a17;
|
||||
--muted: #6b645c;
|
||||
--border: #e2dbd2;
|
||||
--border-field: #8a8378;
|
||||
--accent: #f08a2c;
|
||||
--accent-strong: #a8530a;
|
||||
--accent-soft: rgba(240, 138, 44, .14);
|
||||
--accent-text: #ffffff;
|
||||
--ok: #217346;
|
||||
--warn: #8a6100;
|
||||
--danger: #c0392b;
|
||||
--info: #0b7285;
|
||||
--on-ok: #ffffff;
|
||||
--on-warn: #ffffff;
|
||||
--on-danger: #ffffff;
|
||||
--cat-1: #6941c6;
|
||||
--cat-2: #175cd3;
|
||||
--cat-3: #c11574;
|
||||
--bg-glow: rgba(255, 155, 69, .16);
|
||||
--shadow: 0 6px 20px rgba(60, 40, 20, .10);
|
||||
}
|
||||
|
||||
/* Themeunabhängig: Typografie, Radien, Layout, Bewegung */
|
||||
:root {
|
||||
--font-sans: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
|
||||
--font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
|
||||
--font-mono: ui-monospace, "JetBrains Mono", Menlo, monospace;
|
||||
|
||||
--font-size-base: 15px;
|
||||
--line-height-base: 1.5;
|
||||
--line-height-heading: 1.25;
|
||||
--line-height-reading: 1.75;
|
||||
--reading-max: 46rem;
|
||||
--font-size-page-title: 1.5rem;
|
||||
--font-size-page-title-compact: 1.3rem;
|
||||
--font-size-section-title: 1.1rem;
|
||||
--font-size-wordmark: 1.1rem;
|
||||
--font-size-wordmark-large: 1.5rem;
|
||||
--font-size-small: 0.8rem;
|
||||
--font-size-table-head: 0.75rem;
|
||||
--font-size-metric: 1.6rem;
|
||||
|
||||
--radius-card: 14px;
|
||||
--radius-metric: 12px;
|
||||
--radius-button: 10px;
|
||||
--radius-field: 8px;
|
||||
--radius-pill: 999px;
|
||||
|
||||
--content-max: 76rem;
|
||||
--content-gutter: 1rem;
|
||||
--card-pad-y: 1.1rem;
|
||||
--card-pad-x: 1.3rem;
|
||||
--card-gap: 1.1rem;
|
||||
--login-max: 28rem;
|
||||
--sidebar-width: 15rem;
|
||||
|
||||
/* Ebenen */
|
||||
--z-drag: 200;
|
||||
--z-sticky: 10;
|
||||
--z-dropdown: 40;
|
||||
--z-modal: 100;
|
||||
--z-modal-2: 110;
|
||||
--z-system: 300;
|
||||
--z-toast: 400;
|
||||
--z-tooltip: 500;
|
||||
|
||||
--breakpoint-compact: 40rem; /* nur zur Dokumentation; in @media als Literal verwenden */
|
||||
--transition: 0.12s;
|
||||
|
||||
--control-size: 1.15rem;
|
||||
--switch-width: 2.3rem;
|
||||
--switch-height: 1.3rem;
|
||||
--target-min: 24px;
|
||||
--spinner-size: 1.25rem;
|
||||
--icon-sm: 1rem;
|
||||
--icon-md: 1.25rem;
|
||||
--icon-lg: 1.5rem;
|
||||
--icon-stroke: 1.5;
|
||||
--icon-button: 2rem;
|
||||
--tooltip-max: 18rem;
|
||||
--tooltip-gap: 6px;
|
||||
--tooltip-delay: 0.4s; /* nur zur Dokumentation; im Skript als Millisekunden */
|
||||
--skeleton-radius: 6px;
|
||||
|
||||
--backdrop: rgba(0, 0, 0, .5);
|
||||
--dialog-width: 560px;
|
||||
--dialog-pad: 18px 22px;
|
||||
--dialog-gap: 8px;
|
||||
--shadow-dialog: 0 20px 60px rgba(0, 0, 0, .35);
|
||||
--shadow-menu: 0 10px 30px rgba(0, 0, 0, .25);
|
||||
--shadow-toast: 0 10px 30px rgba(0, 0, 0, .3);
|
||||
|
||||
--focus-ring: 2px solid var(--accent-strong);
|
||||
--focus-offset: 2px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stil „Blau": ersetzt nur die Akzent-Tokens.
|
||||
* Aktivierung per data-accent="blue" am <html>-Element; ohne Attribut gilt Orange.
|
||||
* Gleiche Theme-Logik wie oben: Dunkel ist Fallback, Hell per Systemeinstellung oder data-theme="light".
|
||||
*/
|
||||
:root[data-accent="blue"] {
|
||||
--accent: #6aa9ff;
|
||||
--accent-strong: #6aa9ff;
|
||||
--accent-soft: rgba(106, 169, 255, .14);
|
||||
--accent-text: #0a1428;
|
||||
--bg-glow: rgba(106, 169, 255, .10);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root[data-accent="blue"]:not([data-theme="dark"]) {
|
||||
--accent: #3b82f6;
|
||||
--accent-strong: #1d5fc4;
|
||||
--accent-soft: rgba(29, 95, 196, .14);
|
||||
--accent-text: #ffffff;
|
||||
--bg-glow: rgba(59, 130, 246, .14);
|
||||
}
|
||||
}
|
||||
|
||||
:root[data-accent="blue"][data-theme="light"] {
|
||||
--accent: #3b82f6;
|
||||
--accent-strong: #1d5fc4;
|
||||
--accent-soft: rgba(29, 95, 196, .14);
|
||||
--accent-text: #ffffff;
|
||||
--bg-glow: rgba(59, 130, 246, .14);
|
||||
}
|
||||
|
||||
/* Sichtbarer Tastaturfokus für alle bedienbaren Elemente */
|
||||
:focus-visible {
|
||||
outline: var(--focus-ring);
|
||||
outline-offset: var(--focus-offset);
|
||||
}
|
||||
@ -185,12 +185,23 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Darstellung (System, Dunkel, Hell) aus dem Styleguide; gespeichert wird nur im Browser dieses Geräts.
|
||||
function themeAnwenden(wurzel) {
|
||||
wurzel.querySelectorAll("select[data-theme-wahl]:not([data-bereit])").forEach(function (s) {
|
||||
s.setAttribute("data-bereit", "1");
|
||||
if (!root.styleguideTheme) { s.hidden = true; return; }
|
||||
s.value = root.styleguideTheme.get();
|
||||
s.addEventListener("change", function () { root.styleguideTheme.set(s.value); });
|
||||
});
|
||||
}
|
||||
|
||||
var geplant = false;
|
||||
function alles() {
|
||||
geplant = false;
|
||||
zeitenAnwenden(document);
|
||||
tabellenAnwenden(document);
|
||||
formulareAnwenden(document);
|
||||
themeAnwenden(document);
|
||||
}
|
||||
alles();
|
||||
// Die Seite erneuert Teile von selbst (data-refresh); neue Zeiten und Tabellen werden nachgezogen.
|
||||
|
||||
Reference in New Issue
Block a user