Add browser regression tests and improve accessibility
This commit is contained in:
@@ -256,6 +256,21 @@ npm run size
|
||||
npm pack --dry-run
|
||||
```
|
||||
|
||||
Browser- und Accessibility-Regressionstests laufen mit Playwright und axe-core gegen die Beispielseite. Beim ersten Mal muss Chromium installiert werden:
|
||||
|
||||
```bash
|
||||
npx playwright install chromium
|
||||
npm run test:browser
|
||||
```
|
||||
|
||||
Die Suite prüft Desktop- und Mobile-Ansichten, helle und dunkle Themes, Tastaturinteraktionen und WCAG-A/AA-Regeln. Absichtliche visuelle Änderungen aktualisieren die gespeicherten Referenzbilder mit:
|
||||
|
||||
```bash
|
||||
npm run test:browser:update
|
||||
```
|
||||
|
||||
`npm run test:all` verbindet die schnellen Strukturprüfungen mit den Browser-Tests und ist der empfohlene CI-Einstiegspunkt.
|
||||
|
||||
Neben dem vollständigen Paket können einzelne Schichten importiert werden:
|
||||
|
||||
```css
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
:where(.frost-button--primary) { border-color: var(--frost-color-accent); background: var(--frost-color-accent); color: var(--frost-color-on-accent); }
|
||||
:where(.frost-button--secondary) { border-color: var(--frost-color-border-strong); background: var(--frost-color-surface); color: var(--frost-color-text); }
|
||||
:where(.frost-button--ghost) { border-color: transparent; color: var(--frost-color-accent); }
|
||||
:where(.frost-button--danger) { border-color: var(--frost-color-danger); background: var(--frost-color-danger); color: #fff; }
|
||||
:where(.frost-button--danger) { border-color: var(--frost-color-danger); background: var(--frost-color-danger); color: var(--frost-color-on-danger); }
|
||||
:where(.frost-button--success) { border-color: var(--frost-color-success); background: var(--frost-color-success); color: var(--frost-color-on-success); }
|
||||
:where(.frost-button--link) { min-height: auto; padding: 0; border-color: transparent; color: var(--frost-color-accent); text-decoration: underline; text-underline-offset: 0.15em; }
|
||||
:where(.frost-button--block) { width: 100%; }
|
||||
|
||||
+34
-13
@@ -54,7 +54,7 @@
|
||||
<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" aria-label="Tooltip-Demo">Hover oder Fokus</button>
|
||||
<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>
|
||||
@@ -113,33 +113,54 @@
|
||||
</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">Übersicht</button>
|
||||
<button class="frost-tabs__tab" role="tab" aria-selected="false" aria-controls="tab-panel-two" id="tab-two">Details</button>
|
||||
<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"><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-label="Lädt"></span><span class="frost-text-muted">Beispiel für einen Spinner</span></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';
|
||||
});
|
||||
document.querySelector('#menu-trigger').addEventListener('click', (event) => {
|
||||
const trigger = event.currentTarget;
|
||||
const menuTrigger = document.querySelector('#menu-trigger');
|
||||
const menu = document.querySelector('#example-menu');
|
||||
const open = trigger.getAttribute('aria-expanded') === 'true';
|
||||
trigger.setAttribute('aria-expanded', String(!open));
|
||||
menu.hidden = open;
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
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="tab"]').forEach((tab) => {
|
||||
tab.addEventListener('click', () => {
|
||||
document.querySelectorAll('[role="tab"]').forEach((item) => item.setAttribute('aria-selected', String(item === tab)));
|
||||
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) => {
|
||||
|
||||
+8
-1
@@ -52,8 +52,15 @@
|
||||
"size": "node scripts/size.mjs",
|
||||
"build": "node scripts/build.mjs",
|
||||
"test": "node scripts/check.mjs && node scripts/check-example.mjs",
|
||||
"test:all": "npm test && npm run test:browser",
|
||||
"test:browser": "playwright test",
|
||||
"test:browser:update": "playwright test --update-snapshots",
|
||||
"test:example": "node scripts/check-example.mjs",
|
||||
"generate:utilities": "node scripts/generate-utilities.mjs"
|
||||
},
|
||||
"sideEffects": true
|
||||
"sideEffects": true,
|
||||
"devDependencies": {
|
||||
"@axe-core/playwright": "^4.14.0",
|
||||
"@playwright/test": "^1.65.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +129,11 @@
|
||||
--frost-color-warning: #f3bd63;
|
||||
--frost-color-danger: #ff9388;
|
||||
--frost-color-info: #7fc4ff;
|
||||
--frost-color-on-danger: #2a0907;
|
||||
--frost-color-on-success: #062818;
|
||||
--frost-color-on-warning: #2a1a04;
|
||||
--frost-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
|
||||
--frost-shadow-md: 0 4px 14px rgb(0 0 0 / 0.28);
|
||||
--frost-shadow-lg: 0 16px 45px rgb(0 0 0 / 0.38);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user