diff --git a/bin/ipal-tokens.mjs b/bin/ipal-tokens.mjs new file mode 100755 index 0000000..02b7945 --- /dev/null +++ b/bin/ipal-tokens.mjs @@ -0,0 +1,13 @@ +#!/usr/bin/env node +// ipal-tokens — the brand's design tokens: src/design/tokens.ts → src/design/tokens.css, +// plus a WCAG contrast check (docs/design-tokens.md). +// pnpm exec ipal-tokens → write src/design/tokens.css, print the contrast report +// pnpm exec ipal-tokens --check → fail when the CSS is out of date (CI, ipal-doctor) +// pnpm exec ipal-tokens --in x.ts --out y.css --warn-only + +import { dirname, join } from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' + +const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..') +const { runTokensCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'tokens', 'cli.js')).href) +process.exit(await runTokensCli(process.argv.slice(2))) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 814a85d..f1d2fc5 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,15 @@ Database names follow one rule, and seeding a live site touches only the records fifteen ready page sections and ten page templates. ### New +- **Design-token standard** ([design-tokens.md](./design-tokens.md)): one set of `--ipal-*` names for every site, + only the values differ per brand. `@intecion/ipal-kit/tokens.css` (neutral defaults, light/dark on `data-theme`, + `[data-surface="inverse"]` scope, reduced motion), `@intecion/ipal-kit/tailwind.css` (Tailwind 4 preset: `bg-surface`, + `text-fg`, `text-on-primary`, `py-section`, `rounded-card`, `duration-fast`…), `@intecion/ipal-kit/a11y.css` (the + accessibility widget's CSS through the tokens). New entry `@intecion/ipal-kit/tokens` (`defineTokens`, `tokensToCss`, + `contrastReport`, `fluidClamp`, `IPAL_TOKENS`, `ipalVar`, `IPAL_BREAKPOINTS` …; the first four names also from the root). + New bin `ipal-tokens`: `src/design/tokens.ts` → `src/design/tokens.css` + WCAG contrast check (`--check` for CI). + Templates `DESIGN.md` and `tokens.ts` in `ipal-setup/resources`. `ipal-audit` checks the standard. +- `fluid.css` / `fluid-wide.css`: `--ipal-fs-xs`, `--ipal-fs-h4`, `--ipal-space-stack`, `--ipal-space-section-sm`. - **Block library** ([block-library.md](./block-library.md)): `hero`, `textMedia`, `featureGrid`, `cta`, `richText`, `faq`, `contact`, `gallery`, `testimonials`, `stats`, `steps`, `logos`, `team`, `pricing`, `entryList` — Payload block + server component each, `{ en, pl }` panel, accessibility built in, styled only with design-token utilities. @@ -34,6 +43,12 @@ fifteen ready page sections and ten page templates. `skip (not listed)`. The seed templates (`ipal-site`, `ipal-form`) read it. ### Changed +- **Cookie banner / button colours** read the single token names (`--ipal-surface`, `--ipal-text` …) instead of + `dark:` + `--ipal-*-dark`. With `tokens.css` they switch with the theme. Without it, the built-in fallback follows the + page's `color-scheme` (`light-dark()`): a site without a dark theme no longer gets a dark banner on a dark-mode + device. A `-dark` variable a site still sets is used as the dark fallback. The secondary button's dark fallback text + is `#d4d4d4` (was `#e5e5e5`). +- Lightbox fade: `--ipal-lightbox-duration` defaults to `var(--ipal-duration, 200ms)`; new `--ipal-lightbox-easing`. - **Admin labels:** the link "Open in new tab" checkbox is now **New tab** (with a description) and the table-of-contents switch **Show contents** — shorter labels per admin-ux; the stored fields are unchanged. - **A full seed of a live database is refused:** a run without `only` / `SEED_ONLY` against `NODE_ENV=production` or @@ -48,7 +63,10 @@ fifteen ready page sections and ten page templates. 2. Optional: name the databases `_prod` / `_dev` and add `ipalEnvRules({ databaseName: true })` to see a warning when `DATABASE_URI` points elsewhere. Existing databases need not be renamed. 3. Seed scripts copied from older templates: take the new `SEED_ONLY` handling from `ipal-site` / `ipal-form`. -4. Block library — optional, nothing changes until you turn blocks on. New sites: the starter turns on eight blocks. +4. Optional: adopt the design-token standard (design-tokens.md → "Migrating an existing site"; **ipal-upgrade**). A + site that styles the cookie banner only through `--ipal-*-dark` for its dark theme and does not adopt `tokens.css`: + check the banner in the dark theme (the dark fallback now needs `color-scheme: dark`, which `` sets). +5. Block library — optional, nothing changes until you turn blocks on. New sites: the starter turns on eight blocks. Existing sites move block by block when they get work (an own block with the same slug and fields can be replaced by the library block with `slug`, else a migration with **ipal-migrate-fields**). After turning blocks on: `pnpm generate:types`, `pnpm payload generate:importmap`, Postgres/SQLite `pnpm payload migrate:create`. diff --git a/docs/README.md b/docs/README.md index fb57afa..e09e576 100644 --- a/docs/README.md +++ b/docs/README.md @@ -51,6 +51,7 @@ API details — one file per module: | Stats in the admin panel (no cookies; visitor history with consent) | [stats.md](./stats.md) | | Auto-slug | [slug.md](./slug.md) | | Light / dark theme, switcher | [theme.md](./theme.md) | +| Design tokens (`--ipal-*`, `tokens.css`, `tailwind.css`, `ipal-tokens`, DESIGN.md) | [design-tokens.md](./design-tokens.md) | | R2, `buildImagesConfig`, `MediaPreconnect`, `YouTubeEmbed` | [storage.md](./storage.md) | | Turnstile | [turnstile.md](./turnstile.md) | | Admin panel white-label | [white-label.md](./white-label.md) | diff --git a/docs/accessibility.md b/docs/accessibility.md index 27d8c1e..138ffc8 100644 --- a/docs/accessibility.md +++ b/docs/accessibility.md @@ -75,8 +75,14 @@ the plugin only needs `A11yTexts` for the current locale. ## 2. CSS that reacts to the attributes (MANDATORY — project) -The widget sets attributes on ``. Without this CSS nothing happens. Copy it -into the project's global CSS (adapt it to the design): +The widget sets attributes on ``. Without CSS for them nothing happens. + +**Ready file (1.15.0):** `@import "@intecion/ipal-kit/a11y.css";` in `styles.css` — the rules below, working through +the design tokens ([design-tokens.md](./design-tokens.md)): the readable font swaps `--ipal-font-body/-heading` (set +`--ipal-font-readable` to change it), "no animations" zeroes the `--ipal-duration-*` tokens, contrast + grayscale +combine, the big cursor is built in. Check: tick each option in the widget and see the page change. + +Or copy this into the project's global CSS (adapt it to the design): ```css /* Text size */ diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index 5924cf1..2789af8 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -186,6 +186,7 @@ site), **P** = a test in the panel. Full code: PROGRAMISTA.md §2. | 16 | **Nothing hardcoded** | every text, link, image, file, company data from the panel; domains and keys from `.env` (§2) | — | A, P | | 17 | **Content** | one h1, the answer at the start of each section, facts, internal links, FAQ from real questions, `aiSummary`, sameAs, consistent company data (§0c) | — | S, P | | 18 | **Scaling** | `fluid.css` / `fluid-wide.css`, hero on `--ipal-hero-min-h`, the screen list in §6.11a (including 1366×768) | — | A, browser | +| 19 | **Design tokens** | `DESIGN.md` + `src/design/tokens.ts` → `pnpm exec ipal-tokens` → `src/design/tokens.css`; `styles.css` imports `fluid-wide.css`, `tokens.css`, `tailwind.css`, the brand file (§6.11); fonts in `--font-family-body` / `--font-family-heading` | `defineTokens`, `ipal-tokens` | A (`ipal-tokens --check`), browser (both themes) | **Turnstile works by itself:** both keys in the panel (or env) → the widget shows, and `submitForm` **requires** a token; no keys → no widget, the form works. @@ -879,25 +880,37 @@ upload + ``; **a fixed set of UI icons** → a `select` field with names a `lucide-react` map in `src/components/icons/` (names in a separate file, so the block config does not import React). Code: [section-code.md](./skills/ipal-block/resources/section-code.md). **Never** SVG pasted into a section's JSX. -### 6.11 Styles +### 6.11 Styles — the design-token standard ([design-tokens.md](../design-tokens.md)) -- Tailwind in components; colors and fonts as **tokens** in `styles.css` (`@theme`) - from the `DESIGN.md` source. In components only tokens (`bg-primary`), **never** - `bg-[#ff6600]` or hex. -- Map the plugin's tokens to the project: `--ipal-primary: var(--color-primary)`. -- Fluid typography and spacing: `@import "@intecion/ipal-kit/fluid.css"` + mapping in - `@theme` (`text-h1`, `py-section`, `px-gutter` — PROGRAMISTA §2.5). Do not write `clamp()` - in components; other values from `DESIGN.md` → override the `--ipal-*` variables in `:root`. +Every site uses the same `--ipal-*` token names and Tailwind utilities; only the values differ per brand. +- **The brand lives in two files:** `DESIGN.md` (human, template `ipal-setup/resources/DESIGN.md`) and + `src/design/tokens.ts` (`defineTokens` from `@intecion/ipal-kit/tokens`, template `ipal-setup/resources/tokens.ts`). + `pnpm exec ipal-tokens` writes `src/design/tokens.css` (commit it) and fails on a WCAG AA contrast error. + Never edit the generated file; never put brand values in `styles.css` or in a component. +- **`styles.css` is the same on every site:** `@import "tailwindcss"`, `@intecion/ipal-kit/fluid-wide.css` (or + `fluid.css`), `@intecion/ipal-kit/tokens.css`, `@intecion/ipal-kit/tailwind.css`, `../../design/tokens.css` (last), `@source` of the plugin's dist. +- **Components use only the utilities from the preset:** `bg-bg`, `bg-surface`, `bg-surface-muted`, `bg-inverse`, + `text-fg`, `text-fg-strong`, `text-fg-muted`, `text-on-primary`, `border-border`, `bg-primary hover:bg-primary-hover`, + `text-link`, `outline-focus`, `text-h1`…`text-display`, `py-section`, `px-gutter`, `gap-gap`, `rounded-control`, + `rounded-card`, `shadow-sm`, `max-w-container`, `duration-fast ease-out`. **Never** hex, `bg-[#…]`, `var(--color-…)`, + or `dark:` for colours (the roles switch with `data-theme` themselves). `dark:` only for non-colour differences. +- **Inverted section:** `
` with `settings.background = inverted` → `bg-inverse` + `data-surface="inverse"`; + content inside keeps `text-fg` / `text-link` (the scope re-maps them). +- Fonts via `next/font` with `variable: '--font-family-body'` / `'--font-family-heading'` on `` (not + `--font-body`: a `var()` cycle with the `font-body` utility). Max 2 families. +- Values a CSS variable can't reach (`next/og`, e-mail, `theme-color`): `resolveColors(tokens)` from `@/design/tokens`. + In inline styles / charts: `IPAL_TOKENS.primary` or `ipalVar('primary')`; breakpoints in JS: `IPAL_BREAKPOINTS`. +- A missing role every site would need → **ipal-plugin-gap**; a project-only decorative colour → `styles.css` below the + imports + `DESIGN.md` → Deviations. - JSON-LD only via `` from `/rsc` — never your own `