Add interactive component catalog and browser regression tests
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
playwright-report/
|
||||
test-results/
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
Frost ist eine kleine CSS-Basis für persönliche Websites und Web-Apps. Sie bringt Tokens, zugängliche Grundstyles, Utility-Klassen, Layout-Helfer, Controls und fertige Komponenten mit. Du kannst Frost also entweder eher wie Tailwind mit einzelnen Utilities oder eher wie Bootstrap mit Komponenten verwenden.
|
||||
|
||||
## Komponentenkatalog
|
||||
|
||||
Der interaktive [Komponentenkatalog](examples/index.html) zeigt die öffentliche Komponenten-API mit echten Live-Beispielen, kopierbarem HTML und konkreten Accessibility-Hinweisen. Suche und Theme-Wechsel funktionieren direkt im Browser; Dropdowns, Tabs, Accordions und Modals demonstrieren das erwartete Tastatur- und Fokusverhalten.
|
||||
|
||||
Die visuellen Regressionstests erzeugen für jede Komponentengruppe eigene Referenzbilder in heller und dunkler Darstellung sowie für Desktop- und Mobile-Viewports. Dadurch lässt sich eine Änderung einer konkreten Gruppe zuordnen, ohne eine vollständige Galerieseite vergleichen zu müssen.
|
||||
|
||||
## Einbinden
|
||||
|
||||
Frost hat bewusst getrennte Schichten:
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
}
|
||||
|
||||
dialog.frost-modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; background: transparent; }
|
||||
dialog.frost-modal:not([open]) { display: none; }
|
||||
dialog.frost-modal::backdrop { background: var(--frost-color-backdrop); }
|
||||
dialog.frost-modal[open] { display: grid; }
|
||||
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
@layer catalog {
|
||||
:root { scroll-padding-block-start: var(--frost-space-4); }
|
||||
|
||||
body.catalog-page {
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
background: var(--frost-color-bg);
|
||||
}
|
||||
|
||||
.catalog-shell {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.catalog-sidebar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
align-self: start;
|
||||
height: 100vh;
|
||||
padding: var(--frost-space-6);
|
||||
overflow-y: auto;
|
||||
border-inline-end: 1px solid var(--frost-color-border);
|
||||
background: var(--frost-color-surface);
|
||||
}
|
||||
|
||||
.catalog-brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--frost-space-2);
|
||||
color: var(--frost-color-text);
|
||||
font-size: var(--frost-font-size-lg);
|
||||
font-weight: 800;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.catalog-brand__mark {
|
||||
display: grid;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
place-items: center;
|
||||
border-radius: var(--frost-radius-md);
|
||||
background: var(--frost-color-accent);
|
||||
color: var(--frost-color-on-accent);
|
||||
font-size: var(--frost-font-size-sm);
|
||||
}
|
||||
|
||||
.catalog-sidebar__intro {
|
||||
margin-block: var(--frost-space-3) var(--frost-space-6);
|
||||
color: var(--frost-color-text-muted);
|
||||
font-size: var(--frost-font-size-sm);
|
||||
}
|
||||
|
||||
.catalog-search { margin-block-end: var(--frost-space-6); }
|
||||
.catalog-search .frost-label { font-size: var(--frost-font-size-sm); }
|
||||
|
||||
.catalog-nav {
|
||||
display: grid;
|
||||
gap: var(--frost-space-1);
|
||||
}
|
||||
|
||||
.catalog-nav__label {
|
||||
margin-block-end: var(--frost-space-2);
|
||||
color: var(--frost-color-text-muted);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.catalog-nav__link {
|
||||
padding: var(--frost-space-2) var(--frost-space-3);
|
||||
border-radius: var(--frost-radius-sm);
|
||||
color: var(--frost-color-text-muted);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.catalog-nav__link:hover,
|
||||
.catalog-nav__link:focus-visible {
|
||||
background: var(--frost-color-surface-soft);
|
||||
color: var(--frost-color-text);
|
||||
}
|
||||
|
||||
.catalog-main {
|
||||
width: min(100%, 82rem);
|
||||
padding: var(--frost-space-8) clamp(var(--frost-space-4), 4vw, var(--frost-space-10));
|
||||
}
|
||||
|
||||
.catalog-hero {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: var(--frost-space-6);
|
||||
align-items: start;
|
||||
margin-block-end: var(--frost-space-8);
|
||||
padding: clamp(var(--frost-space-6), 4vw, var(--frost-space-10));
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--frost-color-border);
|
||||
border-radius: var(--frost-radius-xl);
|
||||
background:
|
||||
radial-gradient(circle at 88% 20%, color-mix(in srgb, var(--frost-color-accent) 24%, transparent), transparent 28%),
|
||||
var(--frost-color-surface);
|
||||
}
|
||||
|
||||
.catalog-eyebrow {
|
||||
margin: 0 0 var(--frost-space-2);
|
||||
color: var(--frost-color-accent);
|
||||
font-size: var(--frost-font-size-sm);
|
||||
font-weight: 750;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.catalog-hero h1 {
|
||||
max-width: 14ch;
|
||||
margin: 0;
|
||||
font-size: var(--frost-font-size-2xl);
|
||||
}
|
||||
|
||||
.catalog-hero__copy {
|
||||
max-width: 62ch;
|
||||
margin-block: var(--frost-space-4);
|
||||
color: var(--frost-color-text-muted);
|
||||
font-size: var(--frost-font-size-lg);
|
||||
}
|
||||
|
||||
.catalog-hero__meta { align-items: center; }
|
||||
|
||||
.catalog-empty {
|
||||
padding: var(--frost-space-8);
|
||||
border: 1px dashed var(--frost-color-border-strong);
|
||||
border-radius: var(--frost-radius-lg);
|
||||
color: var(--frost-color-text-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.catalog-list {
|
||||
display: grid;
|
||||
gap: var(--frost-space-8);
|
||||
}
|
||||
|
||||
.catalog-component {
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
scroll-margin-block-start: var(--frost-space-4);
|
||||
}
|
||||
|
||||
.catalog-component[hidden] { display: none; }
|
||||
|
||||
.catalog-component__header {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: var(--frost-space-4);
|
||||
padding: var(--frost-space-6);
|
||||
border-block-end: 1px solid var(--frost-color-border);
|
||||
}
|
||||
|
||||
.catalog-component__header h2 { margin: 0 0 var(--frost-space-2); }
|
||||
.catalog-component__header p { margin: 0; color: var(--frost-color-text-muted); }
|
||||
.catalog-component__header > .frost-badge { align-self: start; }
|
||||
|
||||
.catalog-live {
|
||||
padding: clamp(var(--frost-space-4), 3vw, var(--frost-space-8));
|
||||
background: var(--frost-color-surface-soft);
|
||||
}
|
||||
|
||||
.catalog-live--overlay { min-height: 11rem; }
|
||||
|
||||
.catalog-live__label {
|
||||
display: block;
|
||||
margin-block-end: var(--frost-space-4);
|
||||
color: var(--frost-color-text-muted);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.catalog-details {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.25fr) minmax(16rem, 0.75fr);
|
||||
gap: var(--frost-space-6);
|
||||
padding: var(--frost-space-6);
|
||||
}
|
||||
|
||||
.catalog-code {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--frost-color-border);
|
||||
border-radius: var(--frost-radius-md);
|
||||
background: #101820;
|
||||
}
|
||||
|
||||
.catalog-code__toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--frost-space-3);
|
||||
min-height: 3rem;
|
||||
padding: var(--frost-space-2) var(--frost-space-3);
|
||||
border-block-end: 1px solid #31414d;
|
||||
color: #c9d5dd;
|
||||
font-size: var(--frost-font-size-sm);
|
||||
}
|
||||
|
||||
.catalog-copy {
|
||||
min-height: 2rem;
|
||||
padding: var(--frost-space-1) var(--frost-space-3);
|
||||
border: 1px solid #526675;
|
||||
border-radius: var(--frost-radius-sm);
|
||||
background: #1b2933;
|
||||
color: #f2f7f9;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.catalog-copy:hover { background: #273a47; }
|
||||
|
||||
.catalog-code pre {
|
||||
max-height: 18rem;
|
||||
margin: 0;
|
||||
padding: var(--frost-space-4);
|
||||
overflow: auto;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: #e8f1f5;
|
||||
font-size: var(--frost-font-size-sm);
|
||||
line-height: 1.55;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.catalog-code code { color: inherit; background: transparent; }
|
||||
|
||||
.catalog-a11y {
|
||||
padding: var(--frost-space-5);
|
||||
border: 1px solid color-mix(in srgb, var(--frost-color-success) 40%, var(--frost-color-border));
|
||||
border-radius: var(--frost-radius-md);
|
||||
background: color-mix(in srgb, var(--frost-color-success) 8%, var(--frost-color-surface));
|
||||
}
|
||||
|
||||
.catalog-a11y h3 {
|
||||
margin: 0 0 var(--frost-space-3);
|
||||
color: var(--frost-color-text);
|
||||
font-size: var(--frost-font-size-base);
|
||||
}
|
||||
|
||||
.catalog-a11y ul {
|
||||
display: grid;
|
||||
gap: var(--frost-space-2);
|
||||
margin: 0;
|
||||
padding-inline-start: var(--frost-space-5);
|
||||
color: var(--frost-color-text-muted);
|
||||
font-size: var(--frost-font-size-sm);
|
||||
}
|
||||
|
||||
.catalog-demo-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--frost-space-4);
|
||||
}
|
||||
|
||||
.catalog-demo-card { min-height: 8rem; }
|
||||
.catalog-demo-form { max-width: 34rem; }
|
||||
.catalog-footer { padding-block: var(--frost-space-10) var(--frost-space-4); color: var(--frost-color-text-muted); font-size: var(--frost-font-size-sm); }
|
||||
|
||||
@media (max-width: 64rem) {
|
||||
.catalog-shell { grid-template-columns: 1fr; }
|
||||
.catalog-sidebar {
|
||||
position: static;
|
||||
z-index: 20;
|
||||
height: auto;
|
||||
padding: var(--frost-space-4);
|
||||
overflow: visible;
|
||||
border-inline-end: 0;
|
||||
border-block-end: 1px solid var(--frost-color-border);
|
||||
}
|
||||
.catalog-sidebar__intro { display: none; }
|
||||
.catalog-search { margin-block: var(--frost-space-4); }
|
||||
.catalog-nav { display: flex; overflow-x: auto; padding-block-end: var(--frost-space-1); }
|
||||
.catalog-nav__label { display: none; }
|
||||
.catalog-nav__link { flex: 0 0 auto; }
|
||||
.catalog-main { padding-block-start: var(--frost-space-6); }
|
||||
}
|
||||
|
||||
@media (max-width: 48rem) {
|
||||
.catalog-hero,
|
||||
.catalog-component__header,
|
||||
.catalog-details { grid-template-columns: 1fr; }
|
||||
.catalog-hero__actions { justify-self: start; }
|
||||
.catalog-details { padding: var(--frost-space-4); }
|
||||
.catalog-demo-grid { grid-template-columns: 1fr; }
|
||||
.catalog-component__header { padding: var(--frost-space-5); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
const root = document.documentElement;
|
||||
const themeToggle = document.querySelector("#theme-toggle");
|
||||
const search = document.querySelector("#component-search");
|
||||
const emptyState = document.querySelector("#catalog-empty");
|
||||
const visibleCount = document.querySelector("#visible-count");
|
||||
const components = [...document.querySelectorAll("[data-component]")];
|
||||
|
||||
const formatMarkup = (source) => {
|
||||
const voidElements = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
||||
const lines = source.trim().replace(/>\s*</g, ">\n<").split("\n").map((line) => line.trim()).filter(Boolean);
|
||||
let depth = 0;
|
||||
return lines.map((line) => {
|
||||
if (line.startsWith("</")) depth = Math.max(0, depth - 1);
|
||||
const formatted = `${" ".repeat(depth)}${line}`;
|
||||
const openingTag = line.match(/^<([a-z][\w-]*)\b[^>]*>$/i);
|
||||
if (openingTag && !voidElements.has(openingTag[1].toLowerCase()) && !line.endsWith("/>")) depth += 1;
|
||||
return formatted;
|
||||
}).join("\n");
|
||||
};
|
||||
|
||||
for (const component of components) {
|
||||
const source = component.querySelector("[data-snippet-source]");
|
||||
const code = component.querySelector("[data-snippet-code]");
|
||||
if (source && code) code.textContent = formatMarkup(source.innerHTML);
|
||||
}
|
||||
|
||||
const setThemeState = () => {
|
||||
const dark = root.dataset.theme === "dark";
|
||||
themeToggle.setAttribute("aria-pressed", String(dark));
|
||||
};
|
||||
|
||||
themeToggle.addEventListener("click", () => {
|
||||
root.dataset.theme = root.dataset.theme === "dark" ? "light" : "dark";
|
||||
setThemeState();
|
||||
});
|
||||
setThemeState();
|
||||
|
||||
const copyText = async (text) => {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return;
|
||||
} catch {
|
||||
// Fall back for browsers or embedded previews that deny clipboard permission.
|
||||
}
|
||||
}
|
||||
const field = document.createElement("textarea");
|
||||
field.value = text;
|
||||
field.setAttribute("readonly", "");
|
||||
field.style.position = "fixed";
|
||||
field.style.opacity = "0";
|
||||
document.body.append(field);
|
||||
field.select();
|
||||
document.execCommand("copy");
|
||||
field.remove();
|
||||
};
|
||||
|
||||
document.querySelectorAll("[data-copy-html]").forEach((button) => {
|
||||
button.addEventListener("click", async () => {
|
||||
const component = button.closest("[data-component]");
|
||||
const code = component.querySelector("[data-snippet-code]").textContent;
|
||||
const original = button.textContent;
|
||||
try {
|
||||
await copyText(code);
|
||||
button.textContent = "Kopiert";
|
||||
document.querySelector("#copy-status").textContent = `${component.querySelector("h2").textContent}: HTML kopiert.`;
|
||||
} catch {
|
||||
button.textContent = "Nicht kopiert";
|
||||
document.querySelector("#copy-status").textContent = "Kopieren war nicht möglich. Markiere den Code manuell.";
|
||||
}
|
||||
window.setTimeout(() => { button.textContent = original; }, 1600);
|
||||
});
|
||||
});
|
||||
|
||||
const filterComponents = () => {
|
||||
const query = search.value.trim().toLocaleLowerCase("de-CH");
|
||||
let count = 0;
|
||||
for (const component of components) {
|
||||
const matches = !query || component.dataset.search.toLocaleLowerCase("de-CH").includes(query);
|
||||
component.hidden = !matches;
|
||||
const navLink = document.querySelector(`[href="#${component.id}"]`);
|
||||
if (navLink) navLink.hidden = !matches;
|
||||
if (matches) count += 1;
|
||||
}
|
||||
visibleCount.textContent = `${count} von ${components.length} Gruppen`;
|
||||
emptyState.hidden = count !== 0;
|
||||
};
|
||||
search.addEventListener("input", filterComponents);
|
||||
filterComponents();
|
||||
|
||||
const menuTrigger = document.querySelector("#menu-trigger");
|
||||
const menu = document.querySelector("#example-menu");
|
||||
const setMenuOpen = (open) => {
|
||||
menuTrigger.setAttribute("aria-expanded", String(open));
|
||||
menu.hidden = !open;
|
||||
};
|
||||
menuTrigger.addEventListener("click", () => setMenuOpen(menu.hidden));
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!menu.hidden && !event.target.closest(".frost-dropdown")) setMenuOpen(false);
|
||||
});
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape" && !menu.hidden) {
|
||||
setMenuOpen(false);
|
||||
menuTrigger.focus();
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('[role="tablist"]').forEach((tablist) => {
|
||||
const tabs = [...tablist.querySelectorAll('[role="tab"]')];
|
||||
const activateTab = (tab) => {
|
||||
tabs.forEach((item) => {
|
||||
const selected = item === tab;
|
||||
item.setAttribute("aria-selected", String(selected));
|
||||
item.tabIndex = selected ? 0 : -1;
|
||||
document.getElementById(item.getAttribute("aria-controls")).hidden = !selected;
|
||||
});
|
||||
};
|
||||
tabs.forEach((tab, index) => {
|
||||
tab.addEventListener("click", () => activateTab(tab));
|
||||
tab.addEventListener("keydown", (event) => {
|
||||
const destinations = { ArrowLeft: index - 1, ArrowRight: index + 1, Home: 0, End: tabs.length - 1 };
|
||||
if (!(event.key in destinations)) return;
|
||||
event.preventDefault();
|
||||
const nextTab = tabs[(destinations[event.key] + tabs.length) % tabs.length];
|
||||
activateTab(nextTab);
|
||||
nextTab.focus();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll(".frost-accordion__trigger").forEach((trigger) => {
|
||||
trigger.addEventListener("click", () => {
|
||||
const panel = document.getElementById(trigger.getAttribute("aria-controls"));
|
||||
const open = trigger.getAttribute("aria-expanded") === "true";
|
||||
trigger.setAttribute("aria-expanded", String(!open));
|
||||
panel.hidden = open;
|
||||
});
|
||||
});
|
||||
|
||||
const dialog = document.querySelector("#example-dialog");
|
||||
const dialogTrigger = document.querySelector("#modal-trigger");
|
||||
dialogTrigger.addEventListener("click", () => dialog.showModal());
|
||||
dialog.querySelectorAll("[data-dialog-close]").forEach((button) => {
|
||||
button.addEventListener("click", () => dialog.close(button.value));
|
||||
});
|
||||
dialog.addEventListener("close", () => dialogTrigger.focus());
|
||||
|
||||
document.querySelector("#toast-close").addEventListener("click", (event) => {
|
||||
event.currentTarget.closest(".frost-toast").hidden = true;
|
||||
});
|
||||
@@ -3,173 +3,108 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Frost – Beispiel</title>
|
||||
<meta name="description" content="Interaktiver Komponentenkatalog für das Frost CSS Framework.">
|
||||
<title>Frost – Komponentenkatalog</title>
|
||||
<link rel="stylesheet" href="../frost.css">
|
||||
<style>
|
||||
body { padding-block: var(--frost-space-8); }
|
||||
.example-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--frost-space-4); margin-block-end: var(--frost-space-8); }
|
||||
.example-header h1 { margin-block-end: var(--frost-space-2); }
|
||||
.example-section { margin-block-start: var(--frost-space-8); }
|
||||
.example-section > h2 { margin-block-end: var(--frost-space-4); }
|
||||
.example-sidebar { padding: var(--frost-space-4); background: var(--frost-color-surface-soft); border-inline-end: 1px solid var(--frost-color-border); }
|
||||
.example-sidebar a { display: block; padding: var(--frost-space-2); }
|
||||
.swatch { min-height: 4rem; padding: var(--frost-space-3); border-radius: var(--frost-radius-md); background: var(--frost-color-accent); color: var(--frost-color-on-accent); }
|
||||
</style>
|
||||
<link rel="stylesheet" href="./catalog.css">
|
||||
<script src="./catalog.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<body class="catalog-page">
|
||||
<a class="frost-skip-link" href="#main">Zum Inhalt springen</a>
|
||||
<main id="main" class="frost-container">
|
||||
<header class="example-header">
|
||||
<div>
|
||||
<p class="frost-text-muted">Frost CSS Framework</p>
|
||||
<h1>Kleine Bausteine für eigene Projekte.</h1>
|
||||
</div>
|
||||
<button class="frost-button frost-button--secondary" id="theme-toggle" type="button">Theme wechseln</button>
|
||||
</header>
|
||||
|
||||
<section class="frost-notice frost-notice--info" aria-label="Hinweis zum Framework">
|
||||
Frost ist CSS-only. Das kleine Script auf dieser Seite zeigt nur den Theme-Wechsel und das Öffnen des Menüs.
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-stack">
|
||||
<h2>Tokens und Oberflächen</h2>
|
||||
<div class="frost-grid frost-gap-4 frost-md:grid-cols-2" style="--frost-grid-min: 12rem">
|
||||
<div class="swatch frost-rounded frost-shadow-sm">Akzent</div>
|
||||
<div class="frost-card frost-card--flat frost-p-6">Flache Karte</div>
|
||||
<div class="frost-card frost-card--elevated frost-p-6 frost-hover:shadow">Erhöhte Karte</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-stack">
|
||||
<h2>Feedback und Menüs</h2>
|
||||
<div class="frost-alert frost-alert--warning" role="alert">
|
||||
<strong class="frost-alert__title">Hinweis</strong>
|
||||
<span class="frost-alert__body">Das CSS stellt nur die Darstellung bereit; das Verhalten kommt aus deiner Anwendung.</span>
|
||||
</div>
|
||||
<div class="frost-cluster">
|
||||
<div class="frost-dropdown">
|
||||
<button class="frost-button frost-button--secondary" id="menu-trigger" type="button" aria-expanded="false" aria-controls="example-menu">Menü öffnen</button>
|
||||
<div class="frost-dropdown__menu" id="example-menu" hidden>
|
||||
<a class="frost-dropdown__item" href="#main">Übersicht</a>
|
||||
<button class="frost-dropdown__item" type="button">Eine Aktion</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="frost-button frost-button--primary frost-tooltip" data-frost-tooltip="Ein CSS-only Tooltip">Hover oder Fokus</button>
|
||||
</div>
|
||||
<div class="frost-toast frost-toast--success" role="status"><span>Änderungen gespeichert.</span><button class="frost-button frost-button--icon" type="button" aria-label="Hinweis schließen">×</button></div>
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-stack">
|
||||
<h2>Buttons und Badges</h2>
|
||||
<div class="frost-row">
|
||||
<button class="frost-button frost-button--primary">Primär</button>
|
||||
<button class="frost-button frost-button--secondary">Sekundär</button>
|
||||
<button class="frost-button frost-button--ghost">Ghost</button>
|
||||
<button class="frost-button frost-button--danger">Gefahr</button>
|
||||
<button class="frost-button frost-button--secondary" disabled>Deaktiviert</button>
|
||||
<span class="frost-badge frost-badge--success">Erfolg</span>
|
||||
<span class="frost-badge frost-badge--warning">Warnung</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-grid" style="--frost-grid-min: 18rem">
|
||||
<div class="frost-card">
|
||||
<h2>Formularfelder</h2>
|
||||
<form class="frost-stack" style="--frost-stack-gap: var(--frost-space-4)">
|
||||
<label class="frost-field"><span class="frost-label">Name</span><input class="frost-input" type="text" placeholder="Ada Lovelace"></label>
|
||||
<label class="frost-field"><span class="frost-label">Typ</span><select class="frost-select"><option>Website</option><option>Anwendung</option></select></label>
|
||||
<label class="frost-field"><span class="frost-label">Nachricht</span><textarea class="frost-textarea" placeholder="Schreib etwas..."></textarea></label>
|
||||
<button class="frost-button frost-button--primary" type="submit">Absenden</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="controls" class="frost-sidebar-layout">
|
||||
<aside class="frost-sidebar example-sidebar"><strong>Sidebar</strong><a href="#main">Übersicht</a><a href="#controls">Controls</a></aside>
|
||||
<div class="frost-main frost-card frost-card--flat"><h2>Sidebar-Layout</h2><p class="frost-text-muted">Unter 48rem wird daraus eine normale einspaltige Ansicht.</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-stack">
|
||||
<h2>Utilities</h2>
|
||||
<div class="frost-card frost-stack frost-p-6">
|
||||
<div class="frost-flex frost-flex-wrap frost-items-center frost-justify-between frost-gap-4">
|
||||
<div>
|
||||
<strong class="frost-text-lg">Utility-first, wenn es schnell gehen soll</strong>
|
||||
<p class="frost-mt-2 frost-text-muted">Die Klassen lassen sich direkt kombinieren.</p>
|
||||
</div>
|
||||
<span class="frost-badge frost-badge--info">md:grid-cols-2</span>
|
||||
</div>
|
||||
<div class="frost-grid frost-grid-cols-1 frost-md:grid-cols-2 frost-gap-4">
|
||||
<div class="frost-bg-soft frost-border frost-rounded frost-p-4 frost-hover:shadow">Spacing: <code>frost-p-4</code></div>
|
||||
<div class="frost-bg-accent frost-rounded frost-p-4">Farben: <code>frost-bg-accent</code></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="example-section frost-stack">
|
||||
<h2>Weitere Komponenten</h2>
|
||||
<nav class="frost-navbar frost-border frost-rounded frost-p-4" aria-label="Beispielnavigation">
|
||||
<a class="frost-navbar__brand" href="#main">Frost</a>
|
||||
<div class="frost-navbar__links"><a class="frost-navbar__link" href="#main" aria-current="page">Start</a><a class="frost-navbar__link" href="#controls">Controls</a></div>
|
||||
<div class="catalog-shell">
|
||||
<aside class="catalog-sidebar" aria-label="Katalognavigation">
|
||||
<a class="catalog-brand" href="#main"><span class="catalog-brand__mark" aria-hidden="true">F</span><span>Frost</span></a>
|
||||
<p class="catalog-sidebar__intro">Live-Beispiele, kopierbares Markup und Hinweise für zugängliche Implementierungen.</p>
|
||||
<label class="frost-field catalog-search" for="component-search"><span class="frost-label">Komponenten suchen</span><input class="frost-input" id="component-search" type="search" placeholder="z. B. Modal oder Badge" autocomplete="off"></label>
|
||||
<nav class="catalog-nav" aria-label="Komponentengruppen">
|
||||
<span class="catalog-nav__label">Komponenten</span>
|
||||
<a class="catalog-nav__link" href="#buttons">Buttons</a><a class="catalog-nav__link" href="#forms">Formulare</a><a class="catalog-nav__link" href="#surfaces">Flächen & Badges</a><a class="catalog-nav__link" href="#feedback">Feedback</a><a class="catalog-nav__link" href="#menus">Menüs & Tooltips</a><a class="catalog-nav__link" href="#navigation">Navigation</a><a class="catalog-nav__link" href="#disclosure">Tabs & Accordion</a><a class="catalog-nav__link" href="#data">Daten & Status</a><a class="catalog-nav__link" href="#modal">Modal</a>
|
||||
</nav>
|
||||
<nav class="frost-breadcrumbs" aria-label="Breadcrumb"><a class="frost-breadcrumbs__item" href="#main">Start</a><a class="frost-breadcrumbs__item" href="#controls">Dokumentation</a><span class="frost-breadcrumbs__item" aria-current="page">Komponenten</span></nav>
|
||||
<div class="frost-tabs" role="tablist" aria-label="Beispieltabs">
|
||||
<button class="frost-tabs__tab" role="tab" aria-selected="true" aria-controls="tab-panel-one" id="tab-one" tabindex="0">Übersicht</button>
|
||||
<button class="frost-tabs__tab" role="tab" aria-selected="false" aria-controls="tab-panel-two" id="tab-two" tabindex="-1">Details</button>
|
||||
</div>
|
||||
<div class="frost-tabs__panel" role="tabpanel" id="tab-panel-one" aria-labelledby="tab-one">Ein einfaches Tab-Panel.</div>
|
||||
<div class="frost-tabs__panel" role="tabpanel" id="tab-panel-two" aria-labelledby="tab-two" hidden>Ein zweites Panel für Details.</div>
|
||||
<div class="frost-accordion">
|
||||
<div class="frost-accordion__item"><button class="frost-accordion__trigger" aria-expanded="false" aria-controls="accordion-panel">Was macht Frost?</button><div class="frost-accordion__panel" id="accordion-panel" hidden>Frost verbindet kleine Utilities mit fertigen CSS-Komponenten.</div></div>
|
||||
</div>
|
||||
<div class="frost-table-wrap" role="region" aria-label="Komponententabelle" tabindex="0"><table class="frost-table"><thead><tr><th>Klasse</th><th>Wofür?</th></tr></thead><tbody><tr><td><code>frost-card</code></td><td>Oberfläche mit Border und Radius</td></tr><tr><td><code>frost-grid</code></td><td>Responsive Grid-Grundlage</td></tr></tbody></table></div>
|
||||
<div class="frost-flex frost-items-center frost-gap-3"><span class="frost-spinner" aria-hidden="true"></span><span class="frost-text-muted">Beispiel für einen Spinner</span></div>
|
||||
</section>
|
||||
</main>
|
||||
<script>
|
||||
document.querySelector('#theme-toggle').addEventListener('click', () => {
|
||||
document.documentElement.dataset.theme = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
|
||||
});
|
||||
const menuTrigger = document.querySelector('#menu-trigger');
|
||||
const menu = document.querySelector('#example-menu');
|
||||
const setMenuOpen = (open) => {
|
||||
menuTrigger.setAttribute('aria-expanded', String(open));
|
||||
menu.hidden = !open;
|
||||
};
|
||||
menuTrigger.addEventListener('click', () => setMenuOpen(menu.hidden));
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Escape' && !menu.hidden) {
|
||||
setMenuOpen(false);
|
||||
menuTrigger.focus();
|
||||
}
|
||||
});
|
||||
</aside>
|
||||
|
||||
const tabs = [...document.querySelectorAll('[role="tab"]')];
|
||||
const activateTab = (tab) => {
|
||||
tabs.forEach((item) => {
|
||||
const selected = item === tab;
|
||||
item.setAttribute('aria-selected', String(selected));
|
||||
item.tabIndex = selected ? 0 : -1;
|
||||
});
|
||||
document.querySelectorAll('[role="tabpanel"]').forEach((panel) => { panel.hidden = panel.id !== tab.getAttribute('aria-controls'); });
|
||||
};
|
||||
tabs.forEach((tab, index) => {
|
||||
tab.addEventListener('click', () => activateTab(tab));
|
||||
tab.addEventListener('keydown', (event) => {
|
||||
const keys = { ArrowLeft: index - 1, ArrowRight: index + 1, Home: 0, End: tabs.length - 1 };
|
||||
if (!(event.key in keys)) return;
|
||||
event.preventDefault();
|
||||
const nextTab = tabs[(keys[event.key] + tabs.length) % tabs.length];
|
||||
activateTab(nextTab);
|
||||
nextTab.focus();
|
||||
});
|
||||
});
|
||||
document.querySelector('.frost-accordion__trigger').addEventListener('click', (event) => {
|
||||
const trigger = event.currentTarget;
|
||||
const panel = document.getElementById(trigger.getAttribute('aria-controls'));
|
||||
const open = trigger.getAttribute('aria-expanded') === 'true';
|
||||
trigger.setAttribute('aria-expanded', String(!open));
|
||||
panel.hidden = open;
|
||||
});
|
||||
</script>
|
||||
<main class="catalog-main" id="main">
|
||||
<header class="catalog-hero">
|
||||
<div><p class="catalog-eyebrow">Frost CSS Framework</p><h1>Komponenten, die sich erklären.</h1><p class="catalog-hero__copy">Jedes Beispiel läuft mit echtem Frost-Markup. Kopiere den HTML-Ausschnitt, prüfe die Zustände und beachte den Accessibility-Vertrag.</p><div class="frost-cluster catalog-hero__meta"><span class="frost-badge frost-badge--info" id="visible-count">9 von 9 Gruppen</span><span class="frost-text-muted">Version 0.5.0</span></div></div>
|
||||
<div class="catalog-hero__actions"><button class="frost-button frost-button--secondary" id="theme-toggle" type="button" aria-pressed="false">Theme wechseln</button></div>
|
||||
</header>
|
||||
<p class="catalog-empty" id="catalog-empty" role="status" hidden>Keine Komponente passt zu deiner Suche.</p>
|
||||
<p class="frost-visually-hidden" id="copy-status" aria-live="polite"></p>
|
||||
|
||||
<div class="catalog-list">
|
||||
<section class="catalog-component frost-card" id="buttons" data-component="buttons" data-search="buttons button primär sekundär ghost gefahr disabled loading link block icon">
|
||||
<header class="catalog-component__header"><div><h2>Buttons</h2><p>Aktionen mit klarer Hierarchie, Größen und Zuständen.</p></div><span class="frost-badge">Controls</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-row" data-snippet-source>
|
||||
<button class="frost-button frost-button--primary" type="button">Primär</button><button class="frost-button frost-button--secondary" type="button">Sekundär</button><button class="frost-button frost-button--ghost" type="button">Ghost</button><button class="frost-button frost-button--danger" type="button">Gefahr</button><button class="frost-button frost-button--secondary" type="button" disabled>Deaktiviert</button><button class="frost-button frost-button--primary frost-button--sm" type="button">Kompakt</button><button class="frost-button frost-button--secondary frost-button--icon" type="button" aria-label="Einstellungen">⚙</button>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Verwende echte <code>button</code>-Elemente für Aktionen und Links nur für Navigation.</li><li>Icon-Buttons brauchen einen zugänglichen Namen über <code>aria-label</code>.</li><li>Nutze <code>disabled</code> für nicht verfügbare Aktionen; entferne nie den sichtbaren Fokus.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="forms" data-component="forms" data-search="formular form input select textarea label help fehler validation invalid">
|
||||
<header class="catalog-component__header"><div><h2>Formulare</h2><p>Beschriftete Controls mit Hilfe-, Fehler- und Validierungszuständen.</p></div><span class="frost-badge">Controls</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><form class="frost-stack catalog-demo-form" data-snippet-source>
|
||||
<label class="frost-field"><span class="frost-label">Name</span><input class="frost-input" type="text" autocomplete="name" placeholder="Ada Lovelace"><span class="frost-help">So erscheint dein Name im Profil.</span></label><label class="frost-field"><span class="frost-label">Projekttyp</span><select class="frost-select"><option>Website</option><option>Web-App</option><option>Dokumentation</option></select></label><label class="frost-field"><span class="frost-label">E-Mail</span><input class="frost-input" type="email" value="ada@" aria-invalid="true" aria-describedby="email-error"><span class="frost-error" id="email-error">Gib eine vollständige E-Mail-Adresse ein.</span></label><label class="frost-field"><span class="frost-label">Notiz</span><textarea class="frost-textarea" placeholder="Optionale Details"></textarea></label>
|
||||
</form></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Jedes Control braucht ein sichtbares <code>label</code>.</li><li>Verknüpfe Hilfe und Fehler mit <code>aria-describedby</code>; setze bei Fehlern zusätzlich <code>aria-invalid="true"</code>.</li><li>Placeholder ersetzen keine Beschriftung.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="surfaces" data-component="surfaces" data-search="card karten surface fläche badge elevated interactive status">
|
||||
<header class="catalog-component__header"><div><h2>Flächen & Badges</h2><p>Visuelle Gruppierung und kompakte semantische Statusangaben.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-grid frost-gap-4 frost-md:grid-cols-2" style="--frost-grid-min: 14rem" data-snippet-source>
|
||||
<article class="frost-card frost-card--flat catalog-demo-card"><h3>Flache Karte</h3><p class="frost-text-muted">Für ruhige Inhaltsgruppen.</p><span class="frost-badge frost-badge--info">Entwurf</span></article><article class="frost-card frost-card--elevated frost-card--interactive frost-hover:shadow catalog-demo-card" tabindex="0"><h3>Interaktive Karte</h3><p class="frost-text-muted">Reagiert auf Hover und Fokus.</p><div class="frost-row"><span class="frost-badge frost-badge--success">Bereit</span><span class="frost-badge frost-badge--warning">Prüfen</span></div></article>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Eine Karte ist zunächst nur eine visuelle Gruppe; wähle <code>article</code> oder <code>section</code> nur bei passender Semantik.</li><li>Interaktive Karten brauchen ein echtes interaktives Kind oder vollständige Tastaturunterstützung.</li><li>Vermittle Status nie ausschließlich über Farbe.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="feedback" data-component="feedback" data-search="feedback alert notice toast spinner laden erfolg warnung fehler status">
|
||||
<header class="catalog-component__header"><div><h2>Feedback</h2><p>Hinweise, Warnungen, Toasts und Ladeindikatoren.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-stack" data-snippet-source>
|
||||
<div class="frost-notice frost-notice--info">Neue Einstellungen sind nach dem Speichern aktiv.</div><div class="frost-alert frost-alert--warning" role="alert"><strong class="frost-alert__title">Prüfen</strong><span class="frost-alert__body">Zwei Felder brauchen noch Aufmerksamkeit.</span></div><div class="frost-toast frost-toast--success" role="status"><span>Änderungen gespeichert.</span><button class="frost-button frost-button--icon" id="toast-close" type="button" aria-label="Benachrichtigung schließen">×</button></div><div class="frost-row"><span class="frost-spinner" aria-hidden="true"></span><span>Inhalte werden geladen …</span></div>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Nutze <code>role="alert"</code> nur für dringende, dynamische Meldungen und <code>role="status"</code> für höfliche Updates.</li><li>Der Spinner ist dekorativ; ein Text beschreibt den Ladezustand.</li><li>Toasts dürfen wichtige Informationen nicht ausschließlich zeitlich begrenzt anzeigen.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="menus" data-component="menus" data-search="dropdown menu popover tooltip aria expanded controls">
|
||||
<header class="catalog-component__header"><div><h2>Menüs & Tooltips</h2><p>Kontextuelle Aktionen und kurze ergänzende Hinweise.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live catalog-live--overlay"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-row" data-snippet-source>
|
||||
<div class="frost-dropdown"><button class="frost-button frost-button--secondary" id="menu-trigger" type="button" aria-expanded="false" aria-controls="example-menu">Menü öffnen</button><div class="frost-dropdown__menu" id="example-menu" hidden><a class="frost-dropdown__item" href="#buttons">Buttons</a><a class="frost-dropdown__item" href="#forms">Formulare</a><button class="frost-dropdown__item" type="button">Aktion ausführen</button></div></div><button class="frost-button frost-button--primary frost-tooltip" type="button" data-frost-tooltip="Kurzer Zusatzhinweis">Hover oder Fokus</button>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Synchronisiere <code>aria-expanded</code> und <code>hidden</code> mit dem sichtbaren Zustand.</li><li>Escape schließt das Menü und bringt den Fokus zum Trigger zurück.</li><li>Tooltips ergänzen einen zugänglichen Namen, ersetzen ihn aber nie.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="navigation" data-component="navigation" data-search="navigation navbar breadcrumbs pagination seiten pfad links">
|
||||
<header class="catalog-component__header"><div><h2>Navigation</h2><p>Globale Navigation, Pfadkontext und Seitenauswahl.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-stack" data-snippet-source>
|
||||
<nav class="frost-navbar frost-border frost-rounded frost-p-4" aria-label="Hauptnavigation"><a class="frost-navbar__brand" href="#main">Frost</a><div class="frost-navbar__links"><a class="frost-navbar__link" href="#buttons" aria-current="page">Komponenten</a><a class="frost-navbar__link" href="#data">Tokens</a></div></nav><nav class="frost-breadcrumbs" aria-label="Breadcrumb"><a class="frost-breadcrumbs__item" href="#main">Start</a><a class="frost-breadcrumbs__item" href="#navigation">Dokumentation</a><span class="frost-breadcrumbs__item" aria-current="page">Navigation</span></nav><nav class="frost-pagination" aria-label="Seitennavigation"><a class="frost-pagination__item" href="#navigation" aria-label="Vorherige Seite">‹</a><a class="frost-pagination__item" href="#navigation">1</a><a class="frost-pagination__item" href="#navigation" aria-current="page">2</a><a class="frost-pagination__item" href="#navigation">3</a><a class="frost-pagination__item" href="#navigation" aria-label="Nächste Seite">›</a></nav>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Gib mehreren Navigationen unterscheidbare Namen über <code>aria-label</code>.</li><li>Markiere die aktuelle Position mit <code>aria-current</code>.</li><li>Beschrifte symbolische Vor-/Zurück-Links für Screenreader.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="disclosure" data-component="disclosure" data-search="tabs tablist tabpanel accordion disclosure expanded selected tastatur">
|
||||
<header class="catalog-component__header"><div><h2>Tabs & Accordion</h2><p>Inhalte auf engem Raum strukturiert ein- und ausblenden.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-stack" data-snippet-source>
|
||||
<div><div class="frost-tabs" role="tablist" aria-label="Projektansicht"><button class="frost-tabs__tab" role="tab" aria-selected="true" aria-controls="tab-panel-one" id="tab-one" tabindex="0">Übersicht</button><button class="frost-tabs__tab" role="tab" aria-selected="false" aria-controls="tab-panel-two" id="tab-two" tabindex="-1">Details</button></div><div class="frost-tabs__panel" role="tabpanel" id="tab-panel-one" aria-labelledby="tab-one">Die wichtigsten Projektdaten auf einen Blick.</div><div class="frost-tabs__panel" role="tabpanel" id="tab-panel-two" aria-labelledby="tab-two" hidden>Technische Details und Metadaten.</div></div><div class="frost-accordion"><div class="frost-accordion__item"><button class="frost-accordion__trigger" type="button" aria-expanded="false" aria-controls="accordion-panel">Was macht Frost?</button><div class="frost-accordion__panel" id="accordion-panel" hidden>Frost verbindet semantische Tokens, kleine Utilities und CSS-Komponenten.</div></div></div>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Tabs verwenden <code>tablist</code>, <code>tab</code> und <code>tabpanel</code> mit eindeutigen Beziehungen.</li><li>Pfeiltasten, Home und End bewegen den Fokus innerhalb der Tab-Liste.</li><li>Accordion-Trigger sind Buttons und spiegeln ihren Zustand über <code>aria-expanded</code>.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="data" data-component="data" data-search="daten table tabelle responsive spinner status loading">
|
||||
<header class="catalog-component__header"><div><h2>Daten & Status</h2><p>Responsive Tabellen und klar beschriftete Ladezustände.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div class="frost-stack" data-snippet-source>
|
||||
<div class="frost-table-wrap" role="region" aria-label="Komponentenstatus" tabindex="0"><table class="frost-table"><thead><tr><th scope="col">Komponente</th><th scope="col">Status</th><th scope="col">Version</th></tr></thead><tbody><tr><td>Button</td><td><span class="frost-badge frost-badge--success">Stabil</span></td><td>0.5</td></tr><tr><td>Modal</td><td><span class="frost-badge frost-badge--info">Neu</span></td><td>0.5</td></tr></tbody></table></div><div class="frost-row" role="status"><span class="frost-spinner frost-spinner--sm" aria-hidden="true"></span><span>Status wird aktualisiert …</span></div>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Nutze <code>th</code> und <code>scope</code>, damit Tabellenbeziehungen erhalten bleiben.</li><li>Horizontale Scrollbereiche müssen per Tastatur erreichbar und benannt sein.</li><li>Ein benannter Status ergänzt den dekorativen Spinner.</li></ul></aside></div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-component frost-card" id="modal" data-component="modal" data-search="modal dialog drawer overlay backdrop focus escape">
|
||||
<header class="catalog-component__header"><div><h2>Modal</h2><p>Fokussierte Entscheidungen über dem aktuellen Seitenkontext.</p></div><span class="frost-badge">Components</span></header>
|
||||
<div class="catalog-live"><span class="catalog-live__label">Live-Beispiel</span><div data-snippet-source>
|
||||
<button class="frost-button frost-button--primary" id="modal-trigger" type="button">Modal öffnen</button><dialog class="frost-modal" id="example-dialog" aria-labelledby="dialog-title"><div class="frost-modal__content"><header class="frost-modal__header"><h2 id="dialog-title">Änderung bestätigen</h2><button class="frost-button frost-button--icon" type="button" value="cancel" data-dialog-close aria-label="Modal schließen">×</button></header><div class="frost-modal__body"><p>Die neue Konfiguration wird sofort für alle Nutzerinnen und Nutzer aktiv.</p></div><footer class="frost-modal__footer"><button class="frost-button frost-button--secondary" type="button" value="cancel" data-dialog-close>Abbrechen</button><button class="frost-button frost-button--primary" type="button" value="confirm" data-dialog-close>Bestätigen</button></footer></div></dialog>
|
||||
</div></div>
|
||||
<div class="catalog-details"><div class="catalog-code"><div class="catalog-code__toolbar"><span>HTML</span><button class="catalog-copy" type="button" data-copy-html>HTML kopieren</button></div><pre tabindex="0"><code data-snippet-code></code></pre></div><aside class="catalog-a11y"><h3>Accessibility</h3><ul><li>Bevorzuge das native <code>dialog</code>-Element und öffne es mit <code>showModal()</code>.</li><li>Verbinde den Dialog über <code>aria-labelledby</code> mit einer sichtbaren Überschrift.</li><li>Nach dem Schließen kehrt der Fokus zum auslösenden Button zurück.</li></ul></aside></div>
|
||||
</section>
|
||||
</div>
|
||||
<footer class="catalog-footer">Frost bleibt CSS-only. Das Katalog-Script demonstriert ausschließlich Theme-, Copy- und zugängliches Interaktionsverhalten.</footer>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
|
||||
export default defineConfig({
|
||||
testDir: "./tests/browser",
|
||||
fullyParallel: true,
|
||||
forbidOnly: Boolean(process.env.CI),
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: process.env.CI ? "line" : [["list"], ["html", { open: "never" }]],
|
||||
expect: {
|
||||
timeout: 5_000,
|
||||
toHaveScreenshot: {
|
||||
animations: "disabled",
|
||||
caret: "hide",
|
||||
maxDiffPixelRatio: 0.01,
|
||||
},
|
||||
},
|
||||
use: {
|
||||
baseURL: "http://127.0.0.1:4173",
|
||||
locale: "de-CH",
|
||||
trace: "retain-on-failure",
|
||||
screenshot: "only-on-failure",
|
||||
video: "retain-on-failure",
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: "desktop-chromium",
|
||||
use: {
|
||||
...devices["Desktop Chrome"],
|
||||
colorScheme: "light",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mobile-chromium",
|
||||
use: {
|
||||
...devices["Desktop Chrome"],
|
||||
viewport: { width: 390, height: 844 },
|
||||
colorScheme: "light",
|
||||
},
|
||||
},
|
||||
],
|
||||
webServer: {
|
||||
command: "node tests/browser/serve-example.mjs",
|
||||
url: "http://127.0.0.1:4173/examples/index.html",
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 15_000,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,8 +13,13 @@ const required = [
|
||||
"frost-accordion",
|
||||
"frost-table",
|
||||
"frost-spinner",
|
||||
"#theme-toggle",
|
||||
"#menu-trigger",
|
||||
"id=\"theme-toggle\"",
|
||||
"id=\"menu-trigger\"",
|
||||
"id=\"component-search\"",
|
||||
"data-component=\"buttons\"",
|
||||
"data-component=\"modal\"",
|
||||
"data-copy-html",
|
||||
"catalog-a11y",
|
||||
];
|
||||
const errors = required.filter((value) => !html.includes(value)).map((value) => `examples/index.html: missing demo marker ${value}`);
|
||||
if (!html.includes("aria-selected") || !html.includes("aria-expanded")) errors.push("examples/index.html: interactive ARIA state markers are missing");
|
||||
@@ -22,5 +27,5 @@ if (errors.length) {
|
||||
console.error(errors.join("\n"));
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`Checked ${required.length} utility, component, and interaction markers in examples/index.html.`);
|
||||
console.log(`Checked ${required.length} catalog, component, and interaction markers in examples/index.html.`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const openExample = async (page) => {
|
||||
await page.goto("/examples/index.html");
|
||||
await page.addStyleTag({ content: "html { scroll-behavior: auto !important; }" });
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
};
|
||||
|
||||
const formatViolations = (violations) => violations.map(({ help, helpUrl, id, impact, nodes }) => ({
|
||||
help,
|
||||
helpUrl,
|
||||
id,
|
||||
impact,
|
||||
targets: nodes.map((node) => node.target),
|
||||
}));
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await openExample(page);
|
||||
});
|
||||
|
||||
const visualCases = [
|
||||
{ id: "buttons", name: "buttons" },
|
||||
{ id: "forms", name: "form controls" },
|
||||
{ id: "surfaces", name: "surfaces and badges" },
|
||||
{ id: "feedback", name: "feedback" },
|
||||
{ id: "menus", name: "menus and tooltips", prepare: async (page) => {
|
||||
if (await page.locator("#example-menu").isHidden()) await page.locator("#menu-trigger").click();
|
||||
} },
|
||||
{ id: "navigation", name: "navigation" },
|
||||
{ id: "disclosure", name: "tabs and accordion" },
|
||||
{ id: "data", name: "data and status" },
|
||||
{ id: "modal", name: "modal", target: "#example-dialog .frost-modal__content", prepare: async (page) => {
|
||||
if (!await page.locator("#example-dialog").evaluate((dialog) => dialog.open)) await page.locator("#modal-trigger").click();
|
||||
} },
|
||||
];
|
||||
|
||||
for (const visualCase of visualCases) {
|
||||
test(`${visualCase.name} matches its component baselines`, async ({ page }) => {
|
||||
await page.addStyleTag({ content: ".frost-skip-link { display: none !important; }" });
|
||||
for (const theme of ["light", "dark"]) {
|
||||
await page.locator("html").evaluate((element, selectedTheme) => {
|
||||
element.dataset.theme = selectedTheme;
|
||||
}, theme);
|
||||
await visualCase.prepare?.(page);
|
||||
const target = page.locator(visualCase.target ?? `#${visualCase.id}`);
|
||||
await expect(target).toHaveScreenshot(`component-${visualCase.id}-${theme}.png`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (const theme of ["light", "dark"]) {
|
||||
test(`has no detectable WCAG A or AA violations in the ${theme} theme`, async ({ page }) => {
|
||||
await page.locator("html").evaluate((element, selectedTheme) => {
|
||||
element.dataset.theme = selectedTheme;
|
||||
}, theme);
|
||||
|
||||
const { violations } = await new AxeBuilder({ page })
|
||||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"])
|
||||
.analyze();
|
||||
|
||||
expect(formatViolations(violations), "Axe accessibility violations").toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
test("dropdown exposes state and closes with Escape", async ({ page }) => {
|
||||
const trigger = page.getByRole("button", { name: "Menü öffnen" });
|
||||
const menu = page.locator("#example-menu");
|
||||
|
||||
await trigger.click();
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(menu).toBeVisible();
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "false");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(trigger).toBeFocused();
|
||||
});
|
||||
|
||||
test("tabs support click and arrow-key navigation", async ({ page }) => {
|
||||
const overview = page.getByRole("tab", { name: "Übersicht" });
|
||||
const details = page.getByRole("tab", { name: "Details" });
|
||||
|
||||
await details.click();
|
||||
await expect(details).toHaveAttribute("aria-selected", "true");
|
||||
await expect(page.locator("#tab-panel-two")).toBeVisible();
|
||||
await expect(page.locator("#tab-panel-one")).toBeHidden();
|
||||
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await expect(overview).toBeFocused();
|
||||
await expect(overview).toHaveAttribute("aria-selected", "true");
|
||||
await expect(page.locator("#tab-panel-one")).toBeVisible();
|
||||
});
|
||||
|
||||
test("accordion keeps its control and panel state synchronized", async ({ page }) => {
|
||||
const trigger = page.getByRole("button", { name: "Was macht Frost?" });
|
||||
const panel = page.locator("#accordion-panel");
|
||||
|
||||
await trigger.click();
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(panel).toBeVisible();
|
||||
|
||||
await trigger.click();
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "false");
|
||||
await expect(panel).toBeHidden();
|
||||
});
|
||||
|
||||
test("catalog search filters components and navigation", async ({ page }) => {
|
||||
const search = page.locator("#component-search");
|
||||
|
||||
await search.fill("modal");
|
||||
await expect(page.locator("#modal")).toBeVisible();
|
||||
await expect(page.locator("#buttons")).toBeHidden();
|
||||
await expect(page.locator("#visible-count")).toHaveText("1 von 9 Gruppen");
|
||||
|
||||
await search.fill("unbekannt");
|
||||
await expect(page.locator("#catalog-empty")).toBeVisible();
|
||||
});
|
||||
|
||||
test("copy buttons expose the live HTML snippet", async ({ page }) => {
|
||||
const component = page.locator("#buttons");
|
||||
const code = component.locator("[data-snippet-code]");
|
||||
const copy = component.locator("[data-copy-html]");
|
||||
|
||||
await expect(code).toContainText("frost-button--primary");
|
||||
await copy.click();
|
||||
await expect(copy).toHaveText("Kopiert");
|
||||
await expect(page.locator("#copy-status")).toContainText("Buttons: HTML kopiert");
|
||||
});
|
||||
|
||||
test("modal restores focus to its trigger after closing", async ({ page }) => {
|
||||
const trigger = page.locator("#modal-trigger");
|
||||
const dialog = page.locator("#example-dialog");
|
||||
|
||||
await trigger.click();
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog.getByRole("button", { name: "Modal schließen" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(trigger).toBeFocused();
|
||||
});
|
||||
|
||||
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 59 KiB |
@@ -0,0 +1,46 @@
|
||||
import { createReadStream } from "node:fs";
|
||||
import { stat } from "node:fs/promises";
|
||||
import { createServer } from "node:http";
|
||||
import { extname, resolve, sep } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = resolve(fileURLToPath(new URL("../..", import.meta.url)));
|
||||
const host = "127.0.0.1";
|
||||
const port = Number.parseInt(process.env.FROST_TEST_PORT ?? "4173", 10);
|
||||
const contentTypes = new Map([
|
||||
[".css", "text/css; charset=utf-8"],
|
||||
[".html", "text/html; charset=utf-8"],
|
||||
[".js", "text/javascript; charset=utf-8"],
|
||||
[".mjs", "text/javascript; charset=utf-8"],
|
||||
[".png", "image/png"],
|
||||
[".svg", "image/svg+xml"],
|
||||
]);
|
||||
|
||||
const server = createServer(async (request, response) => {
|
||||
try {
|
||||
const url = new URL(request.url ?? "/", `http://${host}:${port}`);
|
||||
const pathname = decodeURIComponent(url.pathname === "/" ? "/examples/index.html" : url.pathname);
|
||||
const file = resolve(root, `.${pathname}`);
|
||||
|
||||
if (file !== root && !file.startsWith(`${root}${sep}`)) {
|
||||
response.writeHead(403).end("Forbidden");
|
||||
return;
|
||||
}
|
||||
|
||||
const metadata = await stat(file);
|
||||
if (!metadata.isFile()) throw new Error("Not a file");
|
||||
|
||||
response.writeHead(200, {
|
||||
"Cache-Control": "no-store",
|
||||
"Content-Type": contentTypes.get(extname(file)) ?? "application/octet-stream",
|
||||
});
|
||||
createReadStream(file).pipe(response);
|
||||
} catch {
|
||||
response.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" }).end("Not found");
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(port, host, () => {
|
||||
console.log(`Frost example server listening on http://${host}:${port}`);
|
||||
});
|
||||
|
||||