Merge branch 'main' into claude/reference-site-build

This commit is contained in:
Radosław Smoliński
2026-10-29 15:17:24 +01:00
27 changed files with 258 additions and 103 deletions
+4
View File
@@ -23,6 +23,10 @@ fifteen ready page sections and ten page templates.
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`.
- Design tokens: `data-theme="dark"` / `"light"` switches the tokens on any element (a dark panel, a styleguide), not
only on `<html>` (`LIGHT_SELECTOR`, `DARK_SELECTOR`). Inside an inverted section `primary` reads the new
`primary-inverse` / `primary-inverse-text` roles (default: the brand primary), and the contrast report checks primary
buttons there. The `ipal-form` `formClasses.ts` template uses the token utilities and `buttonClass()`.
- **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.
+3 -2
View File
@@ -906,7 +906,8 @@ Every site uses the same `--ipal-*` token names and Tailwind utilities; only the
`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:** `<Section>` with `settings.background = inverted` → `bg-inverse` + `data-surface="inverse"`;
content inside keeps `text-fg` / `text-link` (the scope re-maps them).
content inside keeps `text-fg` / `text-link` / `bg-primary` (the scope re-maps them; a dark brand primary needs
`primary-inverse` / `primary-inverse-text` in `tokens.ts` — the contrast report says when; default: the brand primary). `data-theme="dark"` on any element = a dark panel.
- Fonts via `next/font` with `variable: '--font-family-body'` / `'--font-family-heading'` on `<html>` (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`.
@@ -1054,7 +1055,7 @@ project → **plugin gap**, not a copy.
| `next.config` | `buildImagesConfig`, `buildSecurityHeaders` (`csp`), `buildCsp`, `buildCspHeaders`, `buildAdminCsp` / `buildAdminCspHeaders`, `buildUploadSecurityHeaders`, `withSecurityConfig` (hides `X-Powered-By`) | storage.md, security.md |
| CSP reports, nonces | `createCspReportRoute` (`parseCspReports`, type `CspViolation`), `createProxy({ csp })` + `<SiteProviders nonce>` (dynamic pages only), `createCspNonce`, `CSP_NONCE_HEADER`, `buildReportingEndpoints`, `cspHeaderKey`, `DEFAULT_CSP_REPORT_GROUP`; types `BuildAdminCspArgs`, `CspDirective`, `CspSources`, `CreateCspReportRouteArgs`, `WithSecurityConfigOptions` | security.md |
| Fluid typography and spacing | `fluid.css` / `fluid-wide.css` (`--ipal-*` variables); your own sizes: `fluidClamp`, `FLUID_SCALE`, `FLUID_RANGES` | design-tokens.md |
| Brand colours, fonts, radii, motion, dark mode | `tokens.css` + `tailwind.css`, `src/design/tokens.ts` (`defineTokens`, types `TokensInput`, `ColorInput`, `ColorRole`), `pnpm exec ipal-tokens` (`--check`, `--report`, `--warn-only`); building blocks `tokensToCss`, `defaultTokensCss`, `contrastReport` (`ContrastRow`), `contrastRatio`, `parseColor`, `resolveColors`, `IPAL_TOKENS`, `ipalVar`, `IpalTokenName`, `IPAL_BREAKPOINTS`, `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES`, `DARK_SELECTOR`, `INVERSE_SELECTOR`, `RemValue`, `FluidRange` | design-tokens.md |
| Brand colours, fonts, radii, motion, dark mode | `tokens.css` + `tailwind.css`, `src/design/tokens.ts` (`defineTokens`, types `TokensInput`, `ColorInput`, `ColorRole`), `pnpm exec ipal-tokens` (`--check`, `--report`, `--warn-only`); building blocks `tokensToCss`, `defaultTokensCss`, `contrastReport` (`ContrastRow`), `contrastRatio`, `parseColor`, `resolveColors`, `IPAL_TOKENS`, `ipalVar`, `IpalTokenName`, `IPAL_BREAKPOINTS`, `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES`, `LIGHT_SELECTOR`, `DARK_SELECTOR`, `INVERSE_SELECTOR`, `RemValue`, `FluidRange` | design-tokens.md |
| Accessibility widget CSS | `@intecion/ipal-kit/a11y.css` (works through the tokens) | accessibility.md |
**Consent, analytics, operations**
@@ -1,29 +1,36 @@
// src/components/forms/formClasses.ts — the ONLY place forms are styled. Every
// panel form (RenderForm / BuilderForm) uses it. Values = the project's design
// tokens (DESIGN.md); the plugin ships no styles. Delete keys you don't need.
// panel form (RenderForm / BuilderForm) uses it. Design-token utilities only
// (node_modules/@intecion/ipal-kit/docs/design-tokens.md): a brand changes
// src/design/tokens.ts, never this file. Delete keys you don't need.
import type { BuilderFormClassNames } from '@intecion/ipal-kit/client'
import { buttonClass } from '@intecion/ipal-kit/blocks/rsc'
const control =
'w-full rounded-control border border-border-strong bg-surface px-3 py-2 text-fg placeholder:text-fg-muted ' +
'transition-colors duration-fast ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus ' +
'aria-invalid:border-danger'
export const formClasses: BuilderFormClassNames = {
form: 'grid gap-6',
progress: 'text-sm text-muted', // "Step 1 of 3"
progress: 'text-sm text-fg-muted', // "Step 1 of 3"
step: 'grid gap-4',
stepTitle: 'text-h3 font-semibold',
stepDescription: 'text-muted',
stepTitle: 'text-h4',
stepDescription: 'text-fg-muted',
fields: 'grid grid-cols-12 gap-4',
field: 'col-span-12',
fieldHalf: 'md:col-span-6', // width ≤ 50 in the panel
label: 'mb-1 block font-medium',
input: 'w-full rounded-md border border-border px-3 py-2',
textarea: 'w-full rounded-md border border-border px-3 py-2',
select: 'w-full rounded-md border border-border px-3 py-2',
label: 'mb-1 block font-medium text-fg-strong',
input: control,
textarea: control,
select: control,
checkboxLabel: 'flex items-start gap-2',
choices: 'grid gap-2', // radio / checkbox group <fieldset>
legend: 'mb-1 font-medium',
legend: 'mb-1 font-medium text-fg-strong',
choice: 'flex items-center gap-2',
error: 'mt-1 text-sm text-danger',
formError: 'text-danger',
actions: 'flex gap-3',
back: 'btn btn-secondary', // same classes as Button.tsx variants
submit: 'btn btn-primary',
success: 'rounded-md bg-surface p-6',
formError: 'rounded-control bg-danger-surface p-4 text-danger',
actions: 'flex flex-wrap gap-3',
back: buttonClass('secondary'), // the same looks as the section buttons
submit: buttonClass('primary'),
success: 'rounded-card bg-success-surface p-6 text-success',
}
@@ -759,7 +759,7 @@ CSS: `@intecion/ipal-kit/tokens.css` (neutral `--ipal-*` defaults, light/dark, `
| `ipalVar(name, fallback?)` | `@intecion/ipal-kit/tokens`, `@intecion/ipal-kit` | `var(--ipal-<name>[, fallback])`. |
| `IPAL_BREAKPOINTS` | `@intecion/ipal-kit/tokens`, `@intecion/ipal-kit` | `{ sm: 40, md: 48, lg: 64, xl: 80, '2xl': 96 }` (rem) — for `sizes=` / `matchMedia`. |
| `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES` | `@intecion/ipal-kit/tokens` | The catalogue: colour defaults per theme, theme-independent defaults, fluid names, inverse re-map, the old `-dark` twins. |
| `DARK_SELECTOR`, `INVERSE_SELECTOR` | `@intecion/ipal-kit/tokens` | `:root[data-theme="dark"]`, `[data-surface="inverse"]`. |
| `LIGHT_SELECTOR`, `DARK_SELECTOR`, `INVERSE_SELECTOR` | `@intecion/ipal-kit/tokens` | `:root, [data-theme="light"]`, `:root[data-theme="dark"], [data-theme="dark"]` (a theme on any element), `[data-surface="inverse"]`. |
**Types:** `TokensInput`, `IpalTokenName` (root, `/tokens`), `ColorInput`, `ColorRole`, `ContrastRow`, `FluidRange`, `RemValue` (`/tokens`).
+12 -7
View File
@@ -91,13 +91,13 @@ block has them) → `variant` (sidebar) → `settings` (sidebar: anchor, backgro
| Slug (builder) | Panel name | Own fields | Variants | Accessibility |
|---|---|---|---|---|
| `hero` (`buildHeroBlock`) | Hero / `Sekcja główna` | `media` (image or video), `poster` | `split`, `background`, `centered`, `page` | the first section's heading is the page `h1`; its image is the LCP image (eager, high priority); a background image is decorative (`alt=""`) under a scrim |
| `hero` (`buildHeroBlock`) | Hero / `Sekcja główna` | `media` (image or video), `poster` | `split`, `background`, `centered`, `page` | the first section's heading is the page `h1`; its image is the LCP image (eager, high priority); a background image is decorative (`alt=""`) under a full `bg-overlay` scrim (raise `--ipal-overlay` for very light photos) |
| `textMedia` (`buildTextMediaBlock`) | Text and image | `content` (rich text), `media` | `mediaRight`, `mediaLeft` | reading order = text first on every screen |
| `featureGrid` (`buildFeatureGridBlock`) | Feature grid | `items[]`: `icon` (with `icons`), `media`, `heading`, `text`, `link`; `columns` | `cards`, `list`, `numbered` | a linked feature: its heading is the link and covers the card; a dead link leaves plain text |
| `gallery` (`buildGalleryBlock`) | Gallery | `items[]`: `media`, `caption`; `columns` | `grid`, `masonry` | each image a `LightboxTrigger` (keyboard, focus return, labels from Form messages); captions in `<figcaption>` |
| `faq` (`buildFaqBlock`) | FAQ | `items[]`: `question`, `answer` | `single`, `twoColumn` | native `<details>`/`<summary>`, works without script |
| `cta` (`buildCtaBlock`) | Call to action | `media` | `band`, `card`, `split` | renders nothing without a heading and buttons |
| `contact` (`buildContactBlock`) | Contact | `form` (relation), `content` | `formWithDetails`, `formOnly` | `RenderForm` (labels, errors, consent); details as `<dl>` |
| `contact` (`buildContactBlock`) | Contact | `form` (relation), `content` | `formWithDetails`, `formOnly` | `RenderForm` (labels, errors, consent); details as `<dl>`; the spam check widget turns dark in an inverted section |
| `team` (`buildTeamBlock`) | Team | `items[]`: `media`, `heading` (name), `text` (role), `bio`, `link` | `grid`, `list` | the name is the profile link |
| `pricing` (`buildPricingBlock`) | Pricing | `items[]`: `heading`, `price`, `period`, `text`, `features[]`, `highlighted`, `link`; `highlightLabel`, `note` | — | the highlighted plan carries a text label, not only a colour |
| `logos` (`buildLogosBlock`) | Logos | `items[]`: `media`, `heading` (name), `link` | `row`, `grid` | the name is the alt text when the image has none; no marquee |
@@ -105,7 +105,7 @@ block has them) → `variant` (sidebar) → `settings` (sidebar: anchor, backgro
| `stats` (`buildStatsBlock`) | Key figures / `Liczby` | `items[]`: `value`, `heading` (label), `text` | `row`, `cards` | a `<dl>`; static (no count-up animation) |
| `richText` (`buildRichTextBlock`) | Text | `content`, `tableOfContents` | `narrow`, `wide` | heading anchors + table of contents (`aria-current` on the section being read) |
| `steps` (`buildStepsBlock`) | Steps | `items[]`: `heading`, `text`, `media` | `numbered`, `timeline` | an `<ol>`; the number read as "Step 1" |
| `entryList` (`buildEntryListBlock`) | Entry list | `collection`, `mode` (latest / chosen), `limit`, `entries` | `cards`, `list` | each title links to its entry and covers the card; dates in `<time>` |
| `entryList` (`buildEntryListBlock`) | Entry list | `entryCollection`, `mode` (latest / chosen), `limit`, `entries` | `cards`, `list` | each title links to its entry and covers the card; dates in `<time>` |
**Rules every block meets:** one `<section>` with `aria-labelledby` its heading and `data-ipal-block`; `h1` only in the
first block (`isFirst` from `createPageRoute`), `h2` otherwise, items `h3`; images through `Media` (alt from the media
@@ -140,6 +140,9 @@ the components come from `createBlockRegistry({ icons })`), `testimonials: { col
collection as well), `entryList: { collections: [{ label: { en: 'Projects', pl: 'Realizacje' }, value: 'projects' }] }`
(default posts), `contact: { formsCollection }` (default `forms`).
**Field names** never use a path name Mongoose reserves (`collection`, `schema`, `errors`, `get`, `set`…) — MongoDB is
on every live site and warns on each start (a test enforces it for the library; keep to it in your own `fields`).
**Same panel for the project's own blocks:** `buildItemsField({ fields, labels, rowLabelField, maxRows })`,
`buildMediaField()`, `buildVariantField({ options })`, `buildIconField({ names })`, `buildContentField()`,
`columnsField()` (values `COLUMNS`: `two`, `three`, `four`), `adminText(en, pl)`, `variantOption(value, en, pl)`, and
@@ -167,7 +170,9 @@ plugin's components. `content` needs `resolveLink`; `getEntries` (entry list), `
**UI primitives** (`/blocks/rsc`), each styled once with token utilities: `Section` (anchor, background,
`data-surface` for the inverted token scope, spacing, `Container`), `SectionHeader` (eyebrow, `h1`/`h2`, intro),
`Media` (image or video; `next/image` when passed), `CMSLink` (a panel link → `Anchor`, with `buttonClass`),
`Media` (image or video; `next/image` when passed; `resource` takes any media object, so generated `Media` types fit),
`CMSLink` (a panel link → `Anchor`, with `buttonClass`; a link that wraps something — a logo, a card — and leads nowhere
keeps its content without a link, so an empty link group never hides it),
`buttonClass` / `BUTTON_CLASSES` (button looks by appearance), `Container` / `CONTAINER_WIDTHS`, `Card` / `CARD_CLASS` /
`CARD_INTERACTIVE_CLASS`. Helpers for the project's own blocks: `Buttons` (a block's button row), `headingId(block)`
(the heading id for `aria-labelledby`), `TitleLink` (a card title that links when its link resolves), `GRID_COLUMNS`,
@@ -212,9 +217,9 @@ overwrites an existing file (`--dest`, `--dry-run`).
| `service({ form? })` | hero · textMedia · featureGrid (list) · gallery · faq · contact | — |
| `contact({ form })` | hero (page) · contact · faq | — |
| `blogIndex()` | hero (page) · cta — the entries come from the archive view (docs/content.md) | `postsArchive` |
| `post()` | richText (table of contents) · entryList · cta — for a posts collection with a `layout` field | — |
| `legal('privacyPolicy' \| 'termsOfService')` | hero (page) · richText (table of contents) — structure only; the wording comes from the client | `privacyPolicy`, `termsOfService` |
| `cookiePolicy()` | hero (page) · richText | `cookiePolicy` |
| `post({ title })` | hero (page, the post title as `h1`) · richText (table of contents) · entryList · cta — for a posts collection with a `layout` field | — |
| `legal('privacyPolicy' \| 'termsOfService')` | hero (page) · richText (table of contents), `noindex: true` — structure only; the wording comes from the client | `privacyPolicy`, `termsOfService` |
| `cookiePolicy()` | hero (page) · richText, `noindex: true` | `cookiePolicy` |
| `notFound()` | hero (page) with a button home | `notFound` |
```ts
+18 -7
View File
@@ -11,7 +11,7 @@ Everything here is opt-in. A site that imports none of it looks exactly as befor
| Export | What it is |
|---|---|
| `@intecion/ipal-kit/tokens.css` | neutral defaults for every token: light on `:root`, dark on `:root[data-theme="dark"]`, the inverse scope, reduced motion |
| `@intecion/ipal-kit/tokens.css` | neutral defaults for every token: light on `:root` / `[data-theme="light"]`, dark on `[data-theme="dark"]` (any element), the inverse scope, reduced motion |
| `@intecion/ipal-kit/tailwind.css` | Tailwind 4 preset: `@theme inline` map (utilities below), `dark:` on `data-theme`, `duration-*` / `z-*` utilities, a small base layer, the theme-switch transition |
| `@intecion/ipal-kit/fluid-wide.css` / `fluid.css` | the type and space scale (`--ipal-fs-*`, `--ipal-space-*`, containers, height helpers): grows to 1920 px / 1280 px |
| `@intecion/ipal-kit/a11y.css` | optional CSS for the accessibility widget's attributes, working through the tokens (accessibility.md) |
@@ -88,7 +88,7 @@ Dark mode: `<SiteProviders theme>` (theme.md). Nothing else is needed: the roles
| `secondary` · `secondary-hover` · `secondary-text` | second button (default: neutral strong) | `bg-secondary` · `text-on-secondary` |
| `accent` · `accent-text` | highlight, badge, rating stars (default: primary) | `bg-accent` · `text-accent` · `text-on-accent` |
| `link` · `link-hover` | links in running text | `text-link` · `hover:text-link-hover` |
| `link-inverse` · `focus-inverse` | link and focus ring inside an inverted section | (read through the inverse scope) |
| `link-inverse` · `focus-inverse` · `primary-inverse` · `primary-inverse-text` | link, focus ring and primary button inside an inverted section | (read through the inverse scope) |
| `hover` | neutral hover (ghost button, row) | `bg-hover` |
| `focus` | focus ring | `outline-focus` · `ring-focus` |
| `overlay` | scrim, hero image overlay | `bg-overlay` · `from-overlay` |
@@ -113,13 +113,24 @@ standard). Any CSS colour works.
A project may *add* a breakpoint (`--breakpoint-xs`) as a deviation recorded in `DESIGN.md`. It never moves an existing one.
### Themes on any element
`data-theme="dark"` / `"light"` switches the colour roles on any element, not only `<html>`: a dark panel on a light
page, or a styleguide showing both themes side by side (`<div data-theme="dark" className="bg-bg">…</div>`). The
preset's base layer gives such a panel its text colour; give it a background yourself (`bg-bg` or `bg-surface`). The
Tailwind `dark:` variant follows the nearest `data-theme`.
### Inverted sections
`<Section>` with `settings.background = inverted` renders `bg-inverse` and `data-surface="inverse"`. Inside that
scope, `text`, `text-strong`, `text-muted`, `border(-strong)`, `surface`, `hover`, `link` and `focus` are re-mapped
for the inverse surface, and `color-scheme` flips. Cards, rich text, links and focus rings need no inverse variants:
they keep `text-fg`, `text-link`, `border-border`. `primary` / `accent` are not re-mapped. The contrast report warns
when `primary` on `surface-inverse` is below 3:1.
scope, `text`, `text-strong`, `text-muted`, `border(-strong)`, `surface`, `hover`, `link`, `focus` and `primary`
(+ `primary-hover`, `primary-text`) are re-mapped for the inverse surface, and `color-scheme` flips. Cards, rich text,
links, focus rings and primary buttons need no inverse variants: they keep `text-fg`, `text-link`, `border-border`,
`bg-primary text-on-primary`. `primary` inside reads **`primary-inverse`** / **`primary-inverse-text`** (default: the
brand primary). A dark brand colour vanishes on a dark inverse surface: the contrast report warns (`primary on
surface-inverse` below 3:1, inverse scope), so set a lighter one, per theme: `color: { light: { 'primary-inverse':
'oklch(0.85 0.1 150)', 'primary-inverse-text': 'oklch(0.2 0.05 150)' } }`. `accent` is not re-mapped. Put
`data-surface` and `data-theme` on different elements.
### Legacy `-dark` names
@@ -154,7 +165,7 @@ and focus rings (3:1).
| `fluidClamp(min, max, range)` | the fluid.css `clamp()` for your own sizes; `FLUID_SCALE`, `FLUID_RANGES`, type `FluidRange`, `RemValue` |
| `IPAL_TOKENS`, `ipalVar(name, fallback?)` | `var(--ipal-…)` strings for inline styles, charts, a styleguide page (type `IpalTokenName`) |
| `IPAL_BREAKPOINTS` | breakpoints in rem |
| `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES`, `DARK_SELECTOR`, `INVERSE_SELECTOR`, type `ColorRole` | the catalogue itself |
| `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES`, `LIGHT_SELECTOR`, `DARK_SELECTOR`, `INVERSE_SELECTOR`, type `ColorRole` | the catalogue itself |
Values that CSS variables can't reach (`next/og` images, e-mail templates, `<meta name="theme-color">`): import `tokens`
from `@/design/tokens` and read `resolveColors(tokens).light.primary`.
+7
View File
@@ -68,6 +68,13 @@ import { ThemeSwitcher } from '@intecion/ipal-kit/client'
/>
```
Both icons render: the default is a two-option toggle with the active one highlighted (the `classNames` above).
For one icon that changes with the theme (sun in light, moon in dark), hide the other with the `dark:` variant:
```tsx
<ThemeSwitcher label={themeLabel} classNames={{ light: 'block dark:hidden', dark: 'hidden dark:block' }} />
```
`<button role="switch" aria-checked>` (checked = dark). Which button looks active is decided by CSS
from the attribute on `<html>` (`dark:`), not React state — nothing jumps after hydration.
Hooks for styling: `data-ipal="theme-switch"`, `data-ipal-theme-icon="light|dark"`.
+1
View File
@@ -21,6 +21,7 @@ export {
IPAL_TOKENS,
ipalVar,
LEGACY_DARK_ROLES,
LIGHT_SELECTOR,
parseColor,
resolveColors,
STATIC_DEFAULTS,
@@ -36,7 +36,15 @@ export async function ContactBlock(props: LibraryBlockProps<ContactBlockData>) {
])
const formEl = (
<div className={c.form}>
<RenderForm action={ctx.sendForm} classNames={ctx.formClassNames} form={form as never} linkOptions={linkOptions} locale={locale} texts={texts as BuilderFormTexts} />
<RenderForm
action={ctx.sendForm}
classNames={ctx.formClassNames}
form={form as never}
linkOptions={linkOptions}
locale={locale}
texts={texts as BuilderFormTexts}
turnstileTheme={settings?.background === 'inverted' ? 'dark' : 'page'}
/>
</div>
)
const aside = withDetails && (content || details.length) ? (
@@ -7,8 +7,8 @@ import { cx, parts } from '../../ui/cx.js'
import { TitleLink } from '../../ui/TitleLink.js'
export type EntryListBlockData = {
collection?: null | string
entries?: { relationTo: string; value: unknown }[] | null
entryCollection?: null | string
limit?: null | number
mode?: null | string
} & BaseBlockData
@@ -36,7 +36,7 @@ type Row = { card: EntryCard; collection: string; doc: Record<string, unknown> }
/** The latest entries of a collection, or entries chosen by hand; each card links to its entry. */
export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData>) {
const { classNames, collection, ctx, entries, header, isFirst, limit, links, locale, mode, settings, ui, variant } = props
const { classNames, ctx, entries, entryCollection: collection, header, isFirst, limit, links, locale, mode, settings, ui, variant } = props
const toCard = ctx.entryCard ?? defaultEntryCard
let docs: { collection: string; doc: Record<string, unknown> }[] = []
if (mode === 'selected') {
@@ -19,7 +19,8 @@ export const buildEntryListBlock = defineLibraryBlock<EntryListOptions>({
const latest = (_: unknown, s: { mode?: string } | undefined) => s?.mode !== 'selected'
return [
{
name: 'collection',
// Not `collection`: Mongoose reserves that path name.
name: 'entryCollection',
type: 'select',
defaultValue: collections[0]?.value,
label: adminText('Show', 'Pokaż'),
@@ -10,7 +10,7 @@ export type HeroBlockData = { media?: MediaValue; poster?: MediaValue } & BaseBl
export const HERO_PARTS = {
background: 'relative isolate flex min-h-[var(--ipal-hero-min-h)] items-center overflow-hidden',
backgroundMedia: 'absolute inset-0 -z-10 h-full w-full object-cover',
backgroundOverlay: 'absolute inset-0 -z-10 bg-linear-to-t from-overlay to-transparent',
backgroundOverlay: 'absolute inset-0 -z-10 bg-overlay',
centered: 'mx-auto max-w-narrow text-center',
media: 'h-auto w-full rounded-media object-cover',
page: 'max-w-measure',
+1 -1
View File
@@ -10,7 +10,7 @@ export type SectionHeaderData = { eyebrow?: null | string; heading?: null | stri
export type SectionSettingsData = { [key: string]: unknown; anchor?: null | string; background?: null | string }
/** An upload as stored (an id) or populated (a media document). */
export type MediaValue = null | number | Record<string, unknown> | string | undefined
export type MediaValue = null | number | object | string | undefined
export type LinkData = LinkValue | null | undefined
+7 -1
View File
@@ -27,7 +27,13 @@ export type TemplateOptions = {
}
/** A page for `seed.upsertBySlug('pages', [...])`. */
export type TemplatePage = { layout: Record<string, unknown>[]; slug: TemplateValue; title: TemplateValue }
export type TemplatePage = {
layout: Record<string, unknown>[]
/** Set on legal pages (AGENT.md §0c) — the `noindex` field of buildNoindexField; a collection without it ignores it. */
noindex?: boolean
slug: TemplateValue
title: TemplateValue
}
/** The templates' own page slugs, by page. */
export const TEMPLATE_SLUGS = {
+14 -9
View File
@@ -15,6 +15,9 @@ const cta = (options?: TemplateOptions) => ({
variant: 'band',
})
/** Legal pages stay out of search results (AGENT.md §0c); set `noindex: false` on the result to change it. */
const noindex = (page: TemplatePage): TemplatePage => ({ ...page, noindex: true })
const items = (n: number, make: (i: number) => Record<string, unknown>) => Array.from({ length: n }, (_, i) => make(i + 1))
/** Home: hero, logos, features, text and image, key figures, testimonials, FAQ, call to action. */
@@ -81,11 +84,13 @@ export function blogIndex(options?: TemplateOptions): TemplatePage {
return buildTemplate('blogIndex', { slug: tx('blog', 'blog'), title: tx('Blog', 'Blog') }, [pageHero(tx('Blog', 'Blog'), fill('what the posts are about', 'o czym są wpisy')), cta(options)], options)
}
/** Post body for a posts collection with a `layout` field: text with a table of contents, more posts, call to action. */
/** Post body for a posts collection with a `layout` field: the title as the page header (h1), text with a table of contents, more posts, call to action. */
export function post(options?: TemplateOptions): TemplatePage {
return buildTemplate('post', { slug: fill('post-address', 'adres-wpisu'), title: fill('post title', 'tytuł wpisu') }, [
const title = options?.title ?? fill('post title', 'tytuł wpisu')
return buildTemplate('post', { slug: fill('post-address', 'adres-wpisu'), title }, [
{ blockType: 'hero', header: header(title as Record<string, string>), variant: 'page' },
{ blockType: 'richText', content: richText(fill('post text', 'treść wpisu')), tableOfContents: { label: tx('Contents', 'Spis treści'), show: true }, variant: 'narrow' },
{ blockType: 'entryList', collection: 'posts', header: header(tx('Read also', 'Przeczytaj też')), limit: 3, mode: 'latest', variant: 'cards' },
{ blockType: 'entryList', entryCollection: 'posts', header: header(tx('Read also', 'Przeczytaj też')), limit: 3, mode: 'latest', variant: 'cards' },
cta(options),
], options)
}
@@ -95,10 +100,10 @@ const LEGAL = {
termsOfService: { slug: tx('terms', 'regulamin'), title: tx('Terms of service', 'Regulamin') },
}
/** A legal page (privacy policy, terms): header and text with a table of contents. Structure only — the wording comes from the client. */
/** A legal page (privacy policy, terms): header and text with a table of contents, `noindex`. Structure only — the wording comes from the client. */
export function legal(role: keyof typeof LEGAL, options?: TemplateOptions): TemplatePage {
const { slug, title } = LEGAL[role]
return buildTemplate(role, { slug, title }, [
return noindex(buildTemplate(role, { slug, title }, [
pageHero(title),
{
blockType: 'richText',
@@ -109,15 +114,15 @@ export function legal(role: keyof typeof LEGAL, options?: TemplateOptions): Temp
tableOfContents: { label: tx('Contents', 'Spis treści'), show: true },
variant: 'narrow',
},
], options)
], options))
}
/** Cookie policy: header and text; put the cookie table (CookieTable) on it in your page view or own block. */
/** Cookie policy: header and text, `noindex`; put the cookie table (CookieTable) on it in your page view or own block. */
export function cookiePolicy(options?: TemplateOptions): TemplatePage {
return buildTemplate('cookiePolicy', { slug: tx('cookie-policy', 'polityka-cookies'), title: tx('Cookie policy', 'Polityka cookies') }, [
return noindex(buildTemplate('cookiePolicy', { slug: tx('cookie-policy', 'polityka-cookies'), title: tx('Cookie policy', 'Polityka cookies') }, [
pageHero(tx('Cookie policy', 'Polityka cookies')),
{ blockType: 'richText', content: richText(fill('cookie policy text from the client', 'treść polityki cookies od klienta')), tableOfContents: { show: false }, variant: 'narrow' },
], options)
], options))
}
/** 404: a small header with a button home. */
+7 -4
View File
@@ -11,7 +11,7 @@ import { cx } from './cx.js'
export type ResolveLink = (link: LinkData, locale: string) => null | Promise<null | ResolvedLink> | ResolvedLink
export type CMSLinkProps = {
/** For a link that wraps something (a card, an image): the content instead of the label. */
/** For a link that wraps something (a card, an image): the content instead of the label — shown without a link when the link leads nowhere. */
children?: ReactNode
className?: string
link: LinkData
@@ -28,9 +28,12 @@ export async function CMSLink({
locale,
resolve,
}: { buttonClass?: (appearance?: null | string) => string; Link?: LinkComponent; resolve: ResolveLink } & CMSLinkProps) {
const l = await resolve(link, locale)
const content = children ?? l?.label
if (!l || !content) {return null}
const l = link ? await resolve(link, locale) : null
// A link that wraps something (a logo, a card) and leads nowhere — an empty link group, a deleted page —
// keeps its content as it is; a plain text link without a target renders nothing.
if (!l) {return children ?? null}
const content = children ?? l.label
if (!content) {return null}
const cls = cx(buttonClass(l.appearance), className) || undefined
return (
<Anchor className={cls} href={l.href} internal={l.internal} Link={Link} targetProps={l.targetProps}>
+6
View File
@@ -42,6 +42,9 @@ export const COLOR_DEFAULTS = {
dark: 'color-mix(in oklch, var(--ipal-primary), black 12%)',
light: 'color-mix(in oklch, var(--ipal-primary), black 12%)',
},
// primary inside an inverted section (a dark brand colour vanishes on a dark inverse surface)
'primary-inverse': { dark: 'var(--ipal-primary)', light: 'var(--ipal-primary)' },
'primary-inverse-text': { dark: 'var(--ipal-primary-text)', light: 'var(--ipal-primary-text)' },
'primary-text': { dark: 'oklch(1 0 0)', light: 'oklch(1 0 0)' },
secondary: { dark: 'var(--ipal-text-strong)', light: 'var(--ipal-text-strong)' },
'secondary-hover': {
@@ -76,6 +79,9 @@ export const INVERSE_SCOPE: Partial<Record<ColorRole, string>> = {
focus: 'var(--ipal-focus-inverse)',
hover: onInverse(12),
link: 'var(--ipal-link-inverse)',
primary: 'var(--ipal-primary-inverse)',
'primary-hover': 'color-mix(in oklch, var(--ipal-primary-inverse), black 12%)',
'primary-text': 'var(--ipal-primary-inverse-text)',
surface: onInverse(8),
text: 'var(--ipal-text-inverse)',
'text-muted': onInverse(72),
+12 -2
View File
@@ -33,7 +33,6 @@ const PAIRS: Pair[] = [
{ bg: 'surface-inverse', fg: 'link-inverse', min: 4.5 },
{ bg: 'bg', fg: 'focus', min: 3 },
{ bg: 'surface-inverse', fg: 'focus-inverse', min: 3 },
{ bg: 'surface-inverse', fg: 'primary', level: 'warn', min: 3 },
...(['success', 'warning', 'danger', 'info'] as const).flatMap((state) => [
{ bg: 'bg' as const, fg: state, min: 4.5 },
{ bg: `${state}-surface` as const, fg: state, min: 4.5 },
@@ -42,6 +41,9 @@ const PAIRS: Pair[] = [
/** Content inside an inverted section: muted text and links on the inverse surface. */
const INVERSE_PAIRS: Pair[] = [
// primary is re-mapped to primary-inverse: a dark brand colour needs a lighter one here
{ bg: 'surface-inverse', fg: 'primary', level: 'warn', min: 3 },
{ bg: 'primary', fg: 'primary-text', min: 4.5 },
{ bg: 'surface-inverse', fg: 'text-muted', min: 4.5 },
{ bg: 'surface', fg: 'text', min: 4.5 },
{ bg: 'surface', fg: 'link', min: 4.5 },
@@ -56,7 +58,15 @@ export function contrastReport(input: TokensInput = {}): ContrastRow[] {
const resolved = resolveColors(input)
return themes.flatMap((theme) => {
const colors: Record<string, string> = resolved[theme]
const inverse: Record<string, string> = { ...colors, ...INVERSE_SCOPE }
const outer = (name: string) => (name.startsWith('ipal-') ? colors[name.slice(5)] : undefined)
// Roles the scope does not declare are inherited, i.e. computed on the ancestor: resolve them there first.
const inherited = Object.fromEntries(
Object.entries(colors).flatMap(([role, value]) => {
const rgb = parseColor(value, outer)
return rgb ? [[role, `rgb(${rgb.r * 255} ${rgb.g * 255} ${rgb.b * 255} / ${rgb.a})`]] : []
}),
)
const inverse: Record<string, string> = { ...inherited, ...INVERSE_SCOPE }
const check = (map: Record<string, string>, scope: ContrastRow['scope']) => (pair: Pair): ContrastRow => {
const lookup = (name: string) => (name.startsWith('ipal-') ? map[name.slice(5)] : undefined)
const fg = parseColor(map[pair.fg], lookup)
+21 -10
View File
@@ -9,10 +9,17 @@ import {
import { resolveColors, staticOverrides, type TokensInput } from './define.js'
import { fluidClamp, type RemValue } from './fluid.js'
/** The dark theme. Two parts so it beats a brand's plain `:root` (the brand file comes later). */
export const DARK_SELECTOR = ':root[data-theme="dark"]'
/**
* The themes. `data-theme` works on any element (a dark panel on a light page, a styleguide).
* On <html> the dark selector has two parts so it beats the brand's light block (the brand file comes later).
*/
export const LIGHT_SELECTOR = ':root, [data-theme="light"]'
export const DARK_SELECTOR = ':root[data-theme="dark"], [data-theme="dark"]'
export const INVERSE_SELECTOR = '[data-surface="inverse"]'
const SHADOWS_LIGHT = Object.entries(STATIC_DEFAULTS).filter(([name]) => name.startsWith('shadow-'))
const STATICS = Object.entries(STATIC_DEFAULTS).filter(([name]) => !name.startsWith('shadow-'))
type Entries = Iterable<readonly [string, string]>
function block(selector: string, entries: Entries, indent = ''): string {
@@ -45,17 +52,20 @@ export function defaultTokensCss(): string {
* @intecion/ipal-kit/tokens.css — neutral defaults for every --ipal-* design token
* (generated from src/modules/tokens/catalog.ts; docs/design-tokens.md).
*
* Light values on :root, dark values on :root[data-theme="dark"] (set by <ThemeScript>,
* storage key "theme"). A brand overrides them in src/design/tokens.css, generated by
* Light values on :root, dark values on [data-theme="dark"] (on <html> set by <ThemeScript>,
* storage key "theme"; on any element for a dark panel). A brand overrides them in src/design/tokens.css, generated by
* \`ipal-tokens\` from src/design/tokens.ts and imported after this file.
* Components read only the role names, never "-dark": the roles switch with the theme.
* The type and space scale is in fluid.css / fluid-wide.css — import one of them as well.
*/`,
block(':root', [...colorEntries('light'), ...Object.entries(STATIC_DEFAULTS), ['color-scheme', 'light']]),
block(':root', STATICS),
block(LIGHT_SELECTOR, [...colorEntries('light'), ...SHADOWS_LIGHT, ['color-scheme', 'light']]),
block(DARK_SELECTOR, [...colorEntries('dark'), ...Object.entries(DARK_SHADOWS), ...legacyAliases, ['color-scheme', 'dark']]),
`/* Inverted section (settings.background = inverted): content inside reads the inverse roles. */`,
`/* Inverted section (settings.background = inverted): content inside reads the inverse roles.
Put data-surface and data-theme on different elements: on one, the primary re-map is a var() cycle. */`,
block(INVERSE_SELECTOR, inverseEntries),
block(`${DARK_SELECTOR} ${INVERSE_SELECTOR}`, [['color-scheme', 'light']]),
block('[data-theme="dark"] [data-surface="inverse"]', [['color-scheme', 'light']]),
block('[data-theme="dark"] [data-theme="light"] [data-surface="inverse"]', [['color-scheme', 'dark']]),
`/* No motion for people who asked for none (the a11y widget's "no animations" too). */`,
`@media (prefers-reduced-motion: reduce) {\n${block('html:root', reducedMotion, ' ')}\n}`,
block('html[data-a11y-motion="reduce"]', reducedMotion),
@@ -86,7 +96,8 @@ export function tokensToCss(input: TokensInput, { source = 'src/design/tokens.ts
const statics = Object.entries(staticOverrides(input))
const parts = [header]
if (theme === 'both') {
parts.push(block(':root', [...changed('light', light), ...statics, ...fluidEntries(input)]))
parts.push(block(':root', [...statics, ...fluidEntries(input)]))
parts.push(block(LIGHT_SELECTOR, changed('light', light)))
// brand roles set only for light carry over to dark (resolveColors); other roles keep the dark defaults
parts.push(block(DARK_SELECTOR, changed('dark', dark)))
} else {
@@ -98,8 +109,8 @@ export function tokensToCss(input: TokensInput, { source = 'src/design/tokens.ts
...Object.fromEntries(Object.entries(shadowSource).filter(([name]) => name.startsWith('shadow-'))),
...Object.fromEntries(statics.filter(([name]) => name.startsWith('shadow-'))),
})
parts.push(block(':root', [...all, ...statics, ...shadows, ...fluidEntries(input), scheme]))
parts.push(block(DARK_SELECTOR, [...all, ...shadows, scheme]))
parts.push(block(':root', [...statics, ...fluidEntries(input)]))
parts.push(block(`${LIGHT_SELECTOR}, ${DARK_SELECTOR}`, [...all, ...shadows, scheme]))
parts.push(block(INVERSE_SELECTOR, [['color-scheme', theme === 'dark' ? 'light' : 'dark']]))
}
return parts.filter(Boolean).join('\n\n') + '\n'
+1 -1
View File
@@ -43,7 +43,7 @@ type FluidSizeName<P extends string> = FluidSize extends infer K ? (K extends `$
/** Roles whose light value carries over to dark when the brand sets no dark value. */
export const BRAND_ROLES: readonly ColorRole[] = [
'primary', 'primary-text', 'secondary', 'secondary-text', 'accent', 'accent-text',
'primary', 'primary-text', 'primary-inverse', 'primary-inverse-text', 'secondary', 'secondary-text', 'accent', 'accent-text',
]
function check(keys: Iterable<string>, known: Record<string, unknown>, where: string) {
+1 -1
View File
@@ -3,7 +3,7 @@ export type { ColorRole, IpalTokenName } from './catalog.js'
export { contrastRatio, parseColor } from './color.js'
export { contrastReport } from './contrast.js'
export type { ContrastRow } from './contrast.js'
export { DARK_SELECTOR, defaultTokensCss, INVERSE_SELECTOR, tokensToCss } from './css.js'
export { DARK_SELECTOR, defaultTokensCss, INVERSE_SELECTOR, LIGHT_SELECTOR, tokensToCss } from './css.js'
export { defineTokens, resolveColors } from './define.js'
export type { ColorInput, TokensInput } from './define.js'
export { FLUID_RANGES, FLUID_SCALE, fluidClamp } from './fluid.js'
+3 -2
View File
@@ -134,8 +134,9 @@
letter-spacing: var(--ipal-tracking-heading);
line-height: var(--ipal-lh-heading);
}
/* a scope that re-maps the text roles (data-surface="inverse") also sets its own text colour */
[data-surface] {
/* a scope that re-maps the text roles (data-surface="inverse", a nested data-theme panel) also sets its text colour */
[data-surface],
[data-theme] {
color: var(--ipal-text);
}
:focus-visible {
+44 -29
View File
@@ -2,14 +2,41 @@
* @intecion/ipal-kit/tokens.css — neutral defaults for every --ipal-* design token
* (generated from src/modules/tokens/catalog.ts; docs/design-tokens.md).
*
* Light values on :root, dark values on :root[data-theme="dark"] (set by <ThemeScript>,
* storage key "theme"). A brand overrides them in src/design/tokens.css, generated by
* Light values on :root, dark values on [data-theme="dark"] (on <html> set by <ThemeScript>,
* storage key "theme"; on any element for a dark panel). A brand overrides them in src/design/tokens.css, generated by
* `ipal-tokens` from src/design/tokens.ts and imported after this file.
* Components read only the role names, never "-dark": the roles switch with the theme.
* The type and space scale is in fluid.css / fluid-wide.css — import one of them as well.
*/
:root {
--ipal-container-narrow: 48rem;
--ipal-duration: 250ms;
--ipal-duration-fast: 150ms;
--ipal-duration-slow: 400ms;
--ipal-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
--ipal-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
--ipal-focus-offset: 2px;
--ipal-focus-width: 2px;
--ipal-font-body: var(--font-family-body, ui-sans-serif, system-ui, sans-serif);
--ipal-font-heading: var(--font-family-heading, var(--ipal-font-body));
--ipal-font-mono: var(--font-family-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
--ipal-fw-body: 400;
--ipal-fw-heading: 650;
--ipal-lh-body: 1.6;
--ipal-lh-heading: 1.15;
--ipal-radius: 0.375rem;
--ipal-radius-card: 0.75rem;
--ipal-radius-full: 9999px;
--ipal-radius-media: 0.5rem;
--ipal-radius-sm: 0.25rem;
--ipal-tracking-heading: -0.01em;
--ipal-z-header: 40;
--ipal-z-overlay: 50;
--ipal-z-toast: 60;
}
:root, [data-theme="light"] {
--ipal-bg: oklch(1 0 0);
--ipal-border: oklch(0.922 0 0);
--ipal-border-strong: oklch(0.87 0 0);
@@ -36,6 +63,8 @@
--ipal-link-inverse: var(--ipal-text-inverse);
--ipal-overlay: oklch(0 0 0 / 0.5);
--ipal-primary-hover: color-mix(in oklch, var(--ipal-primary), black 12%);
--ipal-primary-inverse: var(--ipal-primary);
--ipal-primary-inverse-text: var(--ipal-primary-text);
--ipal-primary-text: oklch(1 0 0);
--ipal-secondary: var(--ipal-text-strong);
--ipal-secondary-hover: color-mix(in oklch, var(--ipal-secondary), white 18%);
@@ -44,37 +73,13 @@
--ipal-success-surface: oklch(0.982 0.018 155.826);
--ipal-warning: oklch(0.555 0.163 48.998);
--ipal-warning-surface: oklch(0.987 0.022 95.277);
--ipal-container-narrow: 48rem;
--ipal-duration: 250ms;
--ipal-duration-fast: 150ms;
--ipal-duration-slow: 400ms;
--ipal-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
--ipal-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
--ipal-focus-offset: 2px;
--ipal-focus-width: 2px;
--ipal-font-body: var(--font-family-body, ui-sans-serif, system-ui, sans-serif);
--ipal-font-heading: var(--font-family-heading, var(--ipal-font-body));
--ipal-font-mono: var(--font-family-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
--ipal-fw-body: 400;
--ipal-fw-heading: 650;
--ipal-lh-body: 1.6;
--ipal-lh-heading: 1.15;
--ipal-radius: 0.375rem;
--ipal-radius-card: 0.75rem;
--ipal-radius-full: 9999px;
--ipal-radius-media: 0.5rem;
--ipal-radius-sm: 0.25rem;
--ipal-shadow-lg: 0 16px 32px -8px oklch(0 0 0 / 0.14), 0 4px 8px -4px oklch(0 0 0 / 0.08);
--ipal-shadow-md: 0 4px 8px -2px oklch(0 0 0 / 0.08), 0 2px 4px -2px oklch(0 0 0 / 0.06);
--ipal-shadow-sm: 0 1px 2px 0 oklch(0 0 0 / 0.06), 0 1px 3px 0 oklch(0 0 0 / 0.08);
--ipal-tracking-heading: -0.01em;
--ipal-z-header: 40;
--ipal-z-overlay: 50;
--ipal-z-toast: 60;
color-scheme: light;
}
:root[data-theme="dark"] {
:root[data-theme="dark"], [data-theme="dark"] {
--ipal-bg: oklch(0.145 0 0);
--ipal-border: oklch(0.269 0 0);
--ipal-border-strong: oklch(0.371 0 0);
@@ -101,6 +106,8 @@
--ipal-link-inverse: var(--ipal-text-inverse);
--ipal-overlay: oklch(0 0 0 / 0.65);
--ipal-primary-hover: color-mix(in oklch, var(--ipal-primary), black 12%);
--ipal-primary-inverse: var(--ipal-primary);
--ipal-primary-inverse-text: var(--ipal-primary-text);
--ipal-primary-text: oklch(1 0 0);
--ipal-secondary: var(--ipal-text-strong);
--ipal-secondary-hover: color-mix(in oklch, var(--ipal-secondary), black 12%);
@@ -124,7 +131,8 @@
color-scheme: dark;
}
/* Inverted section (settings.background = inverted): content inside reads the inverse roles. */
/* Inverted section (settings.background = inverted): content inside reads the inverse roles.
Put data-surface and data-theme on different elements: on one, the primary re-map is a var() cycle. */
[data-surface="inverse"] {
--ipal-border: color-mix(in oklch, var(--ipal-text-inverse) 18%, var(--ipal-surface-inverse));
@@ -132,6 +140,9 @@
--ipal-focus: var(--ipal-focus-inverse);
--ipal-hover: color-mix(in oklch, var(--ipal-text-inverse) 12%, var(--ipal-surface-inverse));
--ipal-link: var(--ipal-link-inverse);
--ipal-primary: var(--ipal-primary-inverse);
--ipal-primary-hover: color-mix(in oklch, var(--ipal-primary-inverse), black 12%);
--ipal-primary-text: var(--ipal-primary-inverse-text);
--ipal-surface: color-mix(in oklch, var(--ipal-text-inverse) 8%, var(--ipal-surface-inverse));
--ipal-text: var(--ipal-text-inverse);
--ipal-text-muted: color-mix(in oklch, var(--ipal-text-inverse) 72%, var(--ipal-surface-inverse));
@@ -140,10 +151,14 @@
color-scheme: dark;
}
:root[data-theme="dark"] [data-surface="inverse"] {
[data-theme="dark"] [data-surface="inverse"] {
color-scheme: light;
}
[data-theme="dark"] [data-theme="light"] [data-surface="inverse"] {
color-scheme: dark;
}
/* No motion for people who asked for none (the a11y widget's "no animations" too). */
@media (prefers-reduced-motion: reduce) {
+1 -1
View File
@@ -1300,7 +1300,7 @@
"header.intro": {
"type": "textarea"
},
"collection": {
"entryCollection": {
"type": "select",
"required": true,
"options": [
+20 -1
View File
@@ -119,6 +119,17 @@ describe('faqItemsFromLayout', () => {
})
})
describe('field names', () => {
// Mongoose (MongoDB adapter — every live site) reserves these path names and warns on every start.
const MONGOOSE_RESERVED = ['collection', 'db', 'emit', 'errors', 'get', 'init', 'isModified', 'isNew', 'listeners', 'modelName', 'on', 'once', 'populated', 'prototype', 'remove', 'removeListener', 'save', 'schema', 'set', 'toObject', 'validate']
test('no block uses a name Mongoose reserves', () => {
const offending = blockLibraryManifest.blocks.flatMap((b) =>
b.fields.filter((f) => f.path.split(/\[\]\.|\./).some((seg) => MONGOOSE_RESERVED.includes(seg))).map((f) => `${b.slug}.${f.path}`),
)
expect(offending).toEqual([])
})
})
describe('blockLibraryManifest', () => {
test('lists every block with its variants and fields, the primitives, builders and templates', () => {
expect(blockLibraryManifest.blocks.map((b) => b.slug)).toEqual(LIBRARY_BLOCK_SLUGS)
@@ -167,7 +178,7 @@ describe('page templates', () => {
return
}
for (const [k, x] of Object.entries(o)) {
if (['$form', '$page', 'appearance', 'blockType', 'collection', 'columns', 'limit', 'mode', 'show', 'type', 'variant'].includes(k)) {continue}
if (['$form', '$page', 'appearance', 'blockType', 'columns', 'entryCollection', 'limit', 'mode', 'show', 'type', 'variant'].includes(k)) {continue}
if (typeof x === 'string') {problems.push(`${where}.${k} = "${x}"`)}
else {walk(x, `${where}.${k}`)}
}
@@ -176,6 +187,14 @@ describe('page templates', () => {
expect(problems).toEqual([])
})
test('post: the title is the page header (the only h1); legal pages are noindex', () => {
const page = pageTemplates.post({ title: { en: 'Hello', pl: 'Cześć' } })
expect(page.layout[0]).toMatchObject({ blockType: 'hero', header: { heading: { en: 'Hello', pl: 'Cześć' } }, variant: 'page' })
expect(pageTemplates.legal('privacyPolicy').noindex).toBe(true)
expect(pageTemplates.cookiePolicy().noindex).toBe(true)
expect(pageTemplates.home().noindex).toBeUndefined()
})
test('buttons link to pages by their slug in the default locale', () => {
const json = JSON.stringify(pageTemplates.home())
expect(json).toContain('{"$page":"kontakt"}')
+9 -1
View File
@@ -57,7 +57,7 @@ const header = { eyebrow: 'Eyebrow', heading: 'Section heading', intro: 'Intro t
const SAMPLES: Record<string, Record<string, unknown>> = {
contact: { content: null, form: { id: 'f1', confirmationType: 'message', fields: [{ name: 'name', blockType: 'text', label: 'Name', required: true }], submitButtonLabel: 'Send', title: 'Contact form' }, variant: 'formOnly' },
cta: { links, media: image(), variant: 'band' },
entryList: { collection: 'posts', limit: 3, links, mode: 'latest', variant: 'cards' },
entryList: { entryCollection: 'posts', limit: 3, links, mode: 'latest', variant: 'cards' },
faq: { items: [{ id: 'q1', answer: 'Yes, we do.', question: 'Do you ship?' }], links, variant: 'single' },
featureGrid: { columns: 'three', items: [{ id: 'i1', heading: 'Fast', link: { type: 'internal', page: { slug: 'fast' } }, media: image(), text: 'Quick delivery' }], links, variant: 'cards' },
gallery: { columns: 'three', items: [{ id: 'g1', caption: 'Kitchen', media: image('Kitchen') }, { id: 'g2', media: image('Hall') }], variant: 'grid' },
@@ -180,6 +180,14 @@ describe('block details', () => {
expect(await render(block('logos'))).toContain('alt="Acme"')
})
test('a link that wraps a logo but leads nowhere keeps the logo (an empty link group is stored as { type })', async () => {
const html = await render(block('logos', { items: [{ id: 'o1', heading: 'Acme', link: { type: 'internal' }, media: image('') }] }))
expect(html).toContain('alt="Acme"')
expect(html).not.toContain('<a')
const linked = await render(block('logos', { items: [{ id: 'o1', heading: 'Acme', link: { type: 'internal', page: { slug: 'acme' } }, media: image('') }] }))
expect(linked).toMatch(/<a[^>]*href="\/pl\/acme"[^>]*><img[^>]*alt="Acme"/)
})
test('testimonials: figure/blockquote/figcaption; the rating has a text equivalent per language', async () => {
const en = await render(block('testimonials'))
expect(en).toMatch(/<figure[^>]*>[\s\S]*<blockquote[^>]*>Great work\.<\/blockquote>[\s\S]*<figcaption/)
+29 -3
View File
@@ -48,8 +48,9 @@ describe('shipped CSS files', () => {
test('the preset maps every colour role and keeps the dark variant on data-theme', () => {
const preset = read('src/styles/tailwind.css')
// link-inverse / focus-inverse are read through the inverse scope, not by a utility
for (const role of Object.keys(COLOR_DEFAULTS).filter((r) => r !== 'link-inverse' && r !== 'focus-inverse')) {
// *-inverse roles are read through the inverse scope, not by a utility
const scoped = ['link-inverse', 'focus-inverse', 'primary-inverse', 'primary-inverse-text']
for (const role of Object.keys(COLOR_DEFAULTS).filter((r) => !scoped.includes(r))) {
expect(preset, role).toContain(`var(--ipal-${role})`)
}
expect(preset).toContain('@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));')
@@ -127,10 +128,35 @@ describe('defineTokens / tokensToCss', () => {
expect(light).toEqual(dark)
const css = tokensToCss(tokens)
expect(css).toContain('color-scheme: dark;')
expect(css.match(/--ipal-bg: #070707;/g)).toHaveLength(2)
expect(css.match(/--ipal-bg: #070707;/g)).toHaveLength(1)
expect(css).toContain(':root, [data-theme="light"], :root[data-theme="dark"], [data-theme="dark"] {')
expect(contrastReport(tokens).every((r) => r.theme === 'dark')).toBe(true)
})
test('themes switch on any element, not only <html>', () => {
const defaults = defaultTokensCss()
expect(defaults).toContain(':root, [data-theme="light"] {')
expect(defaults).toContain(':root[data-theme="dark"], [data-theme="dark"] {')
const css = tokensToCss({ color: { dark: { bg: '#111' }, light: { bg: '#fefefe' } } })
expect(css).toMatch(/:root, \[data-theme="light"\] \{\n {2}--ipal-bg: #fefefe;/)
expect(css).toMatch(/:root\[data-theme="dark"\], \[data-theme="dark"\] \{\n {2}--ipal-bg: #111;/)
})
test('primary is re-mapped inside an inverted section and checked there', () => {
expect(defaultTokensCss()).toMatch(/\[data-surface="inverse"\] \{[^}]*--ipal-primary: var\(--ipal-primary-inverse\);/)
const darkBrand = { color: { light: { primary: 'oklch(0.3 0.08 150)' } } }
const warn = contrastReport(darkBrand).find((r) => r.scope === 'inverse' && r.fg === 'primary' && r.theme === 'light')
expect(warn).toMatchObject({ level: 'warn', pass: false })
// the dark theme's inverse surface is light: there the dark brand colour works again
const fixed = contrastReport({
color: {
dark: { 'primary-inverse': 'oklch(0.3 0.08 150)', 'primary-inverse-text': 'oklch(0.98 0 0)' },
light: { ...darkBrand.color.light, 'primary-inverse': 'oklch(0.85 0.1 150)', 'primary-inverse-text': 'oklch(0.2 0.05 150)' },
},
})
expect(fixed.filter((r) => r.scope === 'inverse' && !r.pass)).toEqual([])
})
test('the contrast report fails a low-contrast brand', () => {
const rows = contrastReport({ color: { light: { primary: '#ffeb3b', 'primary-text': '#ffffff' } } })
expect(rows.find((r) => r.theme === 'light' && r.fg === 'primary-text' && r.bg === 'primary')).toMatchObject({ pass: false })