Add utility-first CSS layer and expand component library

This commit is contained in:
2026-11-19 22:53:02 +01:00
parent 69107b7b84
commit d87d22cf0e
17 changed files with 834 additions and 96 deletions
+122 -47
View File
@@ -1,22 +1,29 @@
# Frost CSS Framework
# Frost
Frost is a small, semantic CSS foundation for personal websites and web applications. It provides tokens, accessible base styles, layout primitives, controls, and a few common components without trying to replace Bootstrap or Tailwind.
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.
## Installation
## Einbinden
For a static site:
Frost hat bewusst getrennte Schichten:
- `@fretuks/frost/core`: Tokens, Reset und Accessibility-Grundlagen
- `@fretuks/frost/utility-layer`: Core plus Layout- und Utility-first-Klassen
- `@fretuks/frost/component-layer`: Core plus Controls und fertige Komponenten
- `@fretuks/frost`: alle Schichten zusammen
Für eine statische Website:
```html
<link rel="stylesheet" href="frost/frost.css">
```
For a CSS-aware build:
Mit einem CSS-Build-Tool:
```css
@import "./frost/frost.css";
```
For npm-based projects:
In einem npm-Projekt:
```bash
npm install @fretuks/frost
@@ -26,28 +33,87 @@ npm install @fretuks/frost
@import "@fretuks/frost";
```
## Basic usage
Für die Utility-Schicht:
```css
@import "@fretuks/frost/utility-layer";
```
Für die Komponenten-Schicht:
```css
@import "@fretuks/frost/component-layer";
```
## Grundlegende Nutzung
```html
<main class="frost-container frost-stack">
<section class="frost-card frost-card--elevated">
<h1>Welcome to Frost</h1>
<p class="frost-text-muted">A compact foundation for reusable interfaces.</p>
<a class="frost-button frost-button--primary" href="/start">Get started</a>
<h1>Willkommen bei Frost</h1>
<p class="frost-text-muted">Eine kleine Basis für wiederverwendbare Interfaces.</p>
<a class="frost-button frost-button--primary" href="/start">Los geht's</a>
</section>
</main>
```
## Utilities
Die Utility-Klassen folgen einem einfachen Muster und lassen sich kombinieren:
```html
<section class="frost-grid frost-gap-6 frost-md:grid-cols-2">
<article class="frost-bg-surface frost-border frost-rounded frost-p-6 frost-shadow-sm">
<h2 class="frost-text-xl frost-font-bold">Eine Karte</h2>
<p class="frost-mt-2 frost-text-muted">Abstände, Farben und Layout direkt im Markup.</p>
</article>
</section>
```
Ein paar häufige Utilities:
- Layout: `frost-flex`, `frost-grid`, `frost-flex-wrap`, `frost-items-center`, `frost-justify-between`
- Abstände: `frost-gap-4`, `frost-p-6`, `frost-px-4`, `frost-mt-4`, `frost-mx-auto`
- Typografie: `frost-text-sm`, `frost-text-xl`, `frost-font-semibold`, `frost-text-muted`
- Farben: `frost-bg-surface`, `frost-bg-soft`, `frost-text-accent`, `frost-text-danger`
- Oberfläche: `frost-border`, `frost-rounded`, `frost-shadow`, `frost-overflow-hidden`
Responsive Varianten verwenden die Breakpoints `md` ab `48rem` und `lg` ab `64rem`:
```html
<div class="frost-grid frost-grid-cols-1 frost-md:grid-cols-2 frost-lg:grid-cols-3">
...
</div>
```
Für einfache Zustände gibt es ebenfalls Varianten:
```html
<a class="frost-text-accent frost-hover:text-accent frost-focus:ring" href="/profil">
Zum Profil
</a>
```
Die Utility-Datei wird aus `scripts/generate-utilities.mjs` erzeugt. Wenn sich die gemeinsame Utility-API ändert:
```bash
npm run generate:utilities
```
Utilities verwenden immer den Präfix `frost-`. Responsive Varianten folgen dem Muster `frost-md:*` und `frost-lg:*`; Zustände verwenden `frost-hover:*`, `frost-focus:*` und `frost-active:*`. Die Utility-Schicht enthält keine fertigen Komponenten und kann unabhängig von der Komponenten-Schicht eingesetzt werden.
Zusätzliche Utilities sind unter anderem `frost-relative`, `frost-absolute`, `frost-grid-cols-3`, `frost-col-span-2`, `frost-space-y-4`, `frost-opacity-50`, `frost-z-10` und `frost-truncate`.
## Layout
```html
<div class="frost-grid" style="--frost-grid-min: 14rem">
<article class="frost-card">One</article>
<article class="frost-card">Two</article>
<article class="frost-card">Eins</article>
<article class="frost-card">Zwei</article>
</div>
```
`frost-stack`, `frost-row`, and `frost-grid` expose local custom properties for gap customization:
`frost-stack`, `frost-row` und `frost-grid` haben lokale Custom Properties für den Abstand:
```html
<div class="frost-stack" style="--frost-stack-gap: var(--frost-space-8)">
@@ -55,40 +121,40 @@ npm install @fretuks/frost
</div>
```
Compact and icon controls are available when a project needs smaller repeated actions:
Für kleinere, wiederkehrende Aktionen gibt es kompakte Buttons und Icon-Buttons:
```html
<button class="frost-button frost-button--secondary frost-button--sm">Edit</button>
<button class="frost-button frost-button--ghost frost-button--icon" aria-label="Close">×</button>
<button class="frost-button frost-button--secondary frost-button--sm">Bearbeiten</button>
<button class="frost-button frost-button--ghost frost-button--icon" aria-label="Schließen">×</button>
```
## Forms
## Formulare
```html
<label class="frost-field">
<span class="frost-label">Email</span>
<span class="frost-label">E-Mail</span>
<input class="frost-input" type="email" autocomplete="email">
<span class="frost-help">We will only use this for account notifications.</span>
<span class="frost-help">Wird nur für Benachrichtigungen zum Account verwendet.</span>
</label>
```
## Themes
Without an explicit theme, Frost follows `prefers-color-scheme`. Explicit themes override that behavior:
Ohne explizites Theme richtet sich Frost nach `prefers-color-scheme`. Ein explizites Theme überschreibt dieses Verhalten:
```html
<html data-theme="dark">
```
or:
oder:
```html
<html data-theme="light">
```
Frost does not require JavaScript; a theme switcher can be added later by Iceberg or ordinary vanilla JavaScript.
Frost braucht kein JavaScript. Ein Theme-Schalter kann später mit Iceberg oder ganz normalem Vanilla-JavaScript ergänzt werden.
Projects with additional themes should override Frost's semantic roles rather than reaching into component selectors:
Wenn ein Projekt weitere Themes braucht, sollten die semantischen Rollen von Frost überschrieben werden – nicht die Component-Selektoren:
```css
body.theme-blue {
@@ -100,9 +166,9 @@ body.theme-blue {
}
```
`--frost-color-selection` and `--frost-color-overlay` are available for theme-specific selection and overlay colors. Frost's modal primitives provide visual structure only; opening, closing, focus management, and ARIA behavior remain application responsibilities.
Für Theme-spezifische Auswahl- und Overlay-Farben gibt es `--frost-color-selection` und `--frost-color-overlay`. Die Modal-Styles kümmern sich nur um die Darstellung. Öffnen, Schließen, Fokusmanagement und ARIA-Verhalten bleiben Aufgabe der Anwendung.
Frost's tokens are semantic and intentionally overridable. Add an application theme by setting the roles on a wrapper or document root; component selectors do not need to be redefined:
Die Tokens von Frost sind semantisch und können bewusst überschrieben werden. Ein Anwendungstheme lässt sich auf einem Wrapper oder dem Dokument-Root setzen; die Component-Selektoren müssen dafür nicht neu definiert werden:
```css
[data-theme="ocean"] {
@@ -119,54 +185,56 @@ Frost's tokens are semantic and intentionally overridable. Add an application th
<div class="frost-backdrop" hidden></div>
<section class="frost-modal" role="dialog" aria-modal="true" aria-labelledby="dialog-title" hidden>
<div class="frost-modal__content">
<header class="frost-modal__header"><h2 id="dialog-title">Confirm</h2></header>
<div class="frost-modal__body">Continue?</div>
<header class="frost-modal__header"><h2 id="dialog-title">Bestätigen</h2></header>
<div class="frost-modal__body">Fortfahren?</div>
<footer class="frost-modal__footer"><button class="frost-button frost-button--primary">OK</button></footer>
</div>
</section>
```
## Menus, popovers, and feedback
## Menüs, Popovers und Feedback
Frost supplies visual primitives while application code owns state, positioning updates, and keyboard behavior. Use native buttons, `aria-expanded`, `aria-controls`, and `hidden` so the same markup works with vanilla JavaScript or a framework:
Frost liefert die visuellen Bausteine. Die Anwendung kümmert sich um Zustand, Positionierung und Tastaturverhalten. Am besten native Buttons, `aria-expanded`, `aria-controls` und `hidden` verwenden – dann funktioniert dasselbe Markup mit Vanilla-JavaScript oder einem Framework:
```html
<div class="frost-dropdown">
<button class="frost-button frost-button--secondary" aria-expanded="false" aria-controls="account-menu">Account</button>
<div id="account-menu" class="frost-dropdown__menu" hidden>
<a class="frost-dropdown__item" href="/profile">Profile</a>
<button class="frost-dropdown__item" type="button">Sign out</button>
<a class="frost-dropdown__item" href="/profile">Profil</a>
<button class="frost-dropdown__item" type="button">Abmelden</button>
</div>
</div>
<div class="frost-alert frost-alert--warning" role="alert">
<strong class="frost-alert__title">Check your details</strong>
<span class="frost-alert__body">Some fields need attention.</span>
<strong class="frost-alert__title">Daten prüfen</strong>
<span class="frost-alert__body">Ein paar Felder brauchen noch Aufmerksamkeit.</span>
</div>
<div class="frost-toast-region" aria-live="polite" aria-atomic="true">
<div class="frost-toast frost-toast--success" role="status">
<span>Saved successfully.</span>
<button class="frost-button frost-button--icon" aria-label="Dismiss">×</button>
<span>Erfolgreich gespeichert.</span>
<button class="frost-button frost-button--icon" aria-label="Schließen">×</button>
</div>
</div>
```
Tooltips use `data-frost-tooltip` and should supplement, never replace, an accessible label:
Tooltips verwenden `data-frost-tooltip` und sollten ein zugängliches Label ergänzen, niemals ersetzen:
```html
<button class="frost-button frost-button--icon frost-tooltip" data-frost-tooltip="Copy link" aria-label="Copy link">⧉</button>
<button class="frost-button frost-button--icon frost-tooltip" data-frost-tooltip="Link kopieren" aria-label="Link kopieren">⧉</button>
```
Modal, drawer, dropdown, and popover behavior is deliberately separate from CSS. A behavior layer should toggle `hidden`, synchronize `aria-expanded`, move focus into dialogs, return focus to the trigger, and close on Escape where appropriate. For modal dialogs, use `role="dialog" aria-modal="true"` and a labelled heading.
Das Verhalten von Modal, Drawer, Dropdown und Popover ist bewusst vom CSS getrennt. Eine Behavior-Schicht sollte `hidden` umschalten, `aria-expanded` synchron halten, den Fokus in Dialoge setzen, nach dem Schließen zum Trigger zurückbringen und – wo sinnvoll – mit Escape schließen. Für Modals `role="dialog" aria-modal="true"` und eine beschriftende Überschrift verwenden.
## Responsive utilities
Weitere CSS-only Bausteine sind `frost-navbar`, `frost-breadcrumbs`, `frost-tabs`, `frost-accordion`, `frost-pagination`, `frost-table` und `frost-spinner`. Sie liefern Markup-Struktur und Zustände; Interaktionen wie Tabs umschalten oder Accordion öffnen bleiben bei der Anwendung.
`frost-cluster` is a wrapping flex row for actions, while `frost-hide-mobile`, `frost-show-mobile`, `frost-hide-desktop`, and `frost-responsive` cover common responsive composition needs. Layout components expose local properties such as `--frost-grid-min` and `--frost-cluster-gap` so applications can tune them without new framework classes.
## Responsive Helfer
## Customization
`frost-cluster` ist eine umbrechende Flex-Reihe für Aktionen. `frost-hide-mobile`, `frost-show-mobile`, `frost-hide-desktop` und `frost-responsive` decken ein paar typische Responsive-Fälle ab. Layout-Komponenten haben lokale Properties wie `--frost-grid-min` und `--frost-cluster-gap`, sodass sie ohne neue Framework-Klassen angepasst werden können.
Override semantic tokens in the project layer:
## Anpassen
Semantische Tokens können auf Projektebene überschrieben werden:
```css
:root {
@@ -176,11 +244,11 @@ Override semantic tokens in the project layer:
}
```
The public API uses the `frost-` class prefix and `--frost-*` custom-property prefix to reduce collisions with project CSS and third-party libraries.
Die öffentliche API verwendet den Präfix `frost-` für Klassen und `--frost-*` für Custom Properties. So gibt es weniger Konflikte mit dem eigenen CSS und Libraries von Drittanbietern.
## Package maintenance
## Paket pflegen
The package intentionally ships only the CSS modules, documentation, license, and small dependency-free validation scripts. Example pages remain in the repository but are excluded from the npm tarball.
Das Paket enthält absichtlich nur die CSS-Module, die Doku, die Lizenz und ein paar kleine, dependency-freie Validierungsskripte. Beispielseiten bleiben im Repository, landen aber nicht im npm-Tarball.
```bash
npm run lint
@@ -188,7 +256,14 @@ npm run size
npm pack --dry-run
```
## Philosophy
Neben dem vollständigen Paket können einzelne Schichten importiert werden:
Frost is intentionally smaller than Bootstrap and Tailwind. It establishes predictable foundations while leaving branding, page composition, JavaScript behavior, and specialized components to the project using it.
```css
@import "@fretuks/frost/utilities";
@import "@fretuks/frost/components";
@import "@fretuks/frost/tokens";
```
## Warum das Ganze?
Frost soll eine überschaubare, verlässliche Grundlage sein. Branding, konkrete Seitengestaltung, JavaScript-Verhalten und speziellere Komponenten bleiben dort, wo sie hingehören: im jeweiligen Projekt.