Design tokens: docs, agent guide, skills, audit checks
- docs/design-tokens.md (new module page), README index, CHANGELOG - AGENT.md §0b row 19, §6.11 rewritten for the standard, §6.11a, §7, §10, §12, §14 - ipal-setup stage 5, ipal-block section-code (Section with data-surface, Button, card on token utilities), ipal-site phase 8, ipal-reference (+ api.md /tokens section), ipal-upgrade 1.15.0 note, ipal-audit SKILL + audit.sh token checks - theme.md, consent.md, accessibility.md (a11y.css), lightbox.md, PROGRAMISTA §2.5 - /tokens entry lists its exports explicitly; docs coverage test includes it Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ca8e93eaf4
commit
cf205c59ef
@@ -81,10 +81,12 @@ export async function CMSLink({ link, locale, className, children }: Props) {
|
||||
```ts
|
||||
import type { LinkAppearance } from '@intecion/ipal-kit'
|
||||
|
||||
// design-token utilities only (design-tokens.md) — a brand changes src/design/tokens.ts, never this file
|
||||
const BASE = 'inline-flex items-center gap-2 rounded-control px-5 py-2.5 font-medium transition-colors duration-fast ease-out'
|
||||
const VARIANTS: Record<LinkAppearance, string> = {
|
||||
primary: 'btn btn-primary',
|
||||
secondary: 'btn btn-secondary',
|
||||
link: 'link-arrow',
|
||||
primary: `${BASE} bg-primary text-on-primary hover:bg-primary-hover`,
|
||||
secondary: `${BASE} bg-secondary text-on-secondary hover:bg-secondary-hover`,
|
||||
link: 'text-link underline-offset-4 hover:text-link-hover hover:underline',
|
||||
}
|
||||
|
||||
export function buttonClass(appearance: LinkAppearance): string {
|
||||
@@ -135,18 +137,21 @@ import type { ReactNode } from 'react'
|
||||
import type { SectionSettings } from '@/payload-types'
|
||||
|
||||
const BACKGROUNDS: Record<NonNullable<SectionSettings['background']>, string> = {
|
||||
default: 'bg-background',
|
||||
muted: 'bg-muted',
|
||||
inverted: 'bg-foreground text-background',
|
||||
default: 'bg-bg text-fg',
|
||||
muted: 'bg-surface-muted text-fg',
|
||||
inverted: 'bg-inverse',
|
||||
}
|
||||
|
||||
export function Section({ settings, children }: { settings?: SectionSettings | null; children: ReactNode }) {
|
||||
const background = settings?.background ?? 'default'
|
||||
return (
|
||||
<section
|
||||
id={settings?.anchor || undefined}
|
||||
className={`py-16 md:py-24 ${BACKGROUNDS[settings?.background ?? 'default']}`}
|
||||
// inverse: the tokens inside are re-mapped, so cards/links keep text-fg, text-link (design-tokens.md)
|
||||
data-surface={background === 'inverted' ? 'inverse' : undefined}
|
||||
className={`py-section ${BACKGROUNDS[background]}`}
|
||||
>
|
||||
<div className="container">{children}</div>
|
||||
<div className="mx-auto max-w-container px-gutter">{children}</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -159,10 +164,10 @@ import type { SectionHeaderData } from '@/payload-types'
|
||||
export function SectionHeader({ header, as: H = 'h2' }: { header?: SectionHeaderData | null; as?: 'h1' | 'h2' }) {
|
||||
if (!header?.heading && !header?.eyebrow && !header?.intro) return null
|
||||
return (
|
||||
<header className="mb-10 max-w-2xl">
|
||||
{header.eyebrow && <p className="eyebrow">{header.eyebrow}</p>}
|
||||
{header.heading && <H className="heading">{header.heading}</H>}
|
||||
{header.intro && <p className="lead">{header.intro}</p>}
|
||||
<header className="mb-stack max-w-measure">
|
||||
{header.eyebrow && <p className="mb-2 text-sm font-medium text-fg-muted">{header.eyebrow}</p>}
|
||||
{header.heading && <H className={H === 'h1' ? 'text-h1' : 'text-h2'}>{header.heading}</H>}
|
||||
{header.intro && <p className="mt-4 text-lead">{header.intro}</p>}
|
||||
</header>
|
||||
)
|
||||
}
|
||||
@@ -251,7 +256,7 @@ buildSectionSettingsField(),
|
||||
// src/blocks/FeatureGrid/FeatureCard.tsx
|
||||
export function FeatureCard({ item, locale }: { item: FeatureItem; locale: string }) {
|
||||
return (
|
||||
<article className="card">
|
||||
<article className="flex flex-col gap-4 rounded-card border border-border bg-surface p-6 shadow-sm">
|
||||
<Media resource={item.media} sizes="(min-width: 1024px) 33vw, 100vw" />
|
||||
<h3>{item.heading}</h3>
|
||||
{item.text && <p>{item.text}</p>}
|
||||
@@ -265,7 +270,7 @@ export function FeatureGrid({ header, items, links, settings, locale }: FeatureG
|
||||
return (
|
||||
<Section settings={settings}>
|
||||
<SectionHeader header={header} />
|
||||
<div className="grid gap-6 md:grid-cols-3">
|
||||
<div className="grid gap-gap md:grid-cols-3">
|
||||
{items?.map((item) => <FeatureCard key={item.id} item={item} locale={locale} />)}
|
||||
</div>
|
||||
{links?.map(({ id, link }) => <CMSLink key={id} link={link} locale={locale} className="mt-10" />)}
|
||||
@@ -315,30 +320,23 @@ components. **Never** SVG pasted into a section's JSX.
|
||||
|
||||
## Style
|
||||
|
||||
- **Tailwind in components**, colors and fonts as **tokens** in `styles.css`
|
||||
(`@theme`) — the source is `DESIGN.md` (Impeccable). Components use only token
|
||||
names (`bg-primary`, `text-foreground`), **never** `bg-[#ff6600]` or hex.
|
||||
- Map the plugin tokens to the project tokens — one brand color in one place.
|
||||
- Fonts via `next/font` in the layout, wired to `@theme` with a CSS variable.
|
||||
The design-token standard (`node_modules/@intecion/ipal-kit/docs/design-tokens.md`, AGENT.md §6.11):
|
||||
- **Components use only the preset's utilities** — `bg-bg`, `bg-surface`, `bg-surface-muted`, `bg-inverse`, `text-fg`,
|
||||
`text-fg-strong`, `text-fg-muted`, `text-on-primary`, `border-border`, `text-link`, `outline-focus`, `text-h1`…,
|
||||
`py-section`, `px-gutter`, `gap-gap`, `rounded-control`, `rounded-card`, `shadow-sm`, `max-w-container`.
|
||||
**Never** hex, `bg-[#ff6600]`, `var(--color-…)`, or `dark:` for colours (the roles switch with the theme).
|
||||
- The brand is `src/design/tokens.ts` → `pnpm exec ipal-tokens` → `src/design/tokens.css`; `DESIGN.md` describes it.
|
||||
- Fonts via `next/font` with `variable: '--font-family-body'` / `'--font-family-heading'` on `<html>`.
|
||||
- No CSS Modules and no `style={{…}}` — exception: a dynamic value from data.
|
||||
- Visual variants → `Record<Variant, string>` (§6.3), not ternary chains.
|
||||
|
||||
```css
|
||||
/* src/app/(frontend)/styles.css */
|
||||
/* src/app/(frontend)/styles.css — the same on every site */
|
||||
@import "tailwindcss";
|
||||
@import "@intecion/ipal-kit/fluid-wide.css";
|
||||
@import "@intecion/ipal-kit/tokens.css";
|
||||
@import "@intecion/ipal-kit/tailwind.css";
|
||||
@import "../../design/tokens.css"; /* generated by ipal-tokens from src/design/tokens.ts */
|
||||
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
|
||||
|
||||
@theme {
|
||||
--color-primary: oklch(0.62 0.19 45);
|
||||
--color-background: oklch(0.99 0 0);
|
||||
--color-foreground: oklch(0.2 0 0);
|
||||
--color-muted: oklch(0.96 0 0);
|
||||
--font-sans: var(--font-body); /* next/font: variable '--font-body' */
|
||||
}
|
||||
|
||||
:root {
|
||||
--ipal-primary: var(--color-primary); /* cookie banner, Turnstile = brand color */
|
||||
--ipal-radius: 0.75rem;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user