Docs: image lightbox page, agent guide, skills, audit check, upgrade note

- docs/lightbox.md: setup, sizes, styling, overrides, migration from a
  hand-made modal or glightbox
- AGENT.md (§6.9, §7 catalog, §7.1, §12), ipal-reference (option, wiring,
  api.md section), ipal-site and ipal-block steps, PROGRAMISTA §6 row 48
- ipal-audit warns about lightbox libraries
- notifications.md, richtext.md, media.md, frontend.md, README index

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-27 14:49:38 +01:00
co-authored by Claude Opus 5.5
parent 476c3ac1df
commit 7eacf1e713
13 changed files with 287 additions and 7 deletions
+1
View File
@@ -38,6 +38,7 @@ API details — one file per module:
| Integrations (`site-integrations` global, statuses, test email) | [integrations.md](./integrations.md) |
| Links / CTA: buildLinkField, buildLinksField, resolveLinkHref, rowLabel | [links.md](./links.md) |
| Media: collection, file names, optimization, placeholders, `mediaImageProps` | [media.md](./media.md) |
| Image lightbox: enlarge a thumbnail, galleries, rich text images | [lightbox.md](./lightbox.md) |
| Site MCP server | [mcp.md](./mcp.md) |
| Form messages | [notifications.md](./notifications.md) |
| System pages, 404, generateStaticParams | [pages.md](./pages.md) |
+8
View File
@@ -739,6 +739,11 @@ Skill: **ipal-nav**.
`server-only`, secrets. Types are allowed (`import type`).
6. Plugin hooks from `@intecion/ipal-kit/client` (`useForm`, `useConsentContext`…).
7. a11y labels (`aria-label`, "Close", "Next slide") — from the panel, via props.
8. **An enlarged image is never a hand-made modal** (no `useState(index)` + `div role="dialog"`,
`glightbox`, `photoswipe`, a link to the raw file in a new tab) — `<LightboxTrigger>` around the
thumbnail (a client component you render from a server block with plain `lightboxImage(…)` data),
one `<SiteProviders lightbox>`, labels from Notifications → Lightbox (lightbox.md). `ipal-audit`
warns about lightbox libraries and hand-made image dialogs.
### 6.10 Icons
@@ -893,6 +898,7 @@ project → **plugin gap**, not a copy.
|---|---|---|
| R2, file names, optimization, preview | `buildR2Storage`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` | storage.md |
| Image / video in `<Media>` | `mediaImageProps`, `videoProps`, `MEDIA_SIZES` | storage.md |
| Enlarge an image (card, gallery, product, rich text) | `<SiteProviders lightbox>` + `<LightboxTrigger group image={lightboxImage(media, { size })}>` (`/client`), `RenderRichText lightbox`, `useLightbox`; labels: `ipalKit({ lightbox: true })` → Notifications → Lightbox | lightbox.md |
| YouTube without cookies before a click | `<YouTubeEmbed>` (`/client`) | storage.md |
| `next.config` | `buildImagesConfig`, `buildSecurityHeaders`, `buildCsp`, `buildUploadSecurityHeaders` | storage.md, security.md |
| Fluid typography and spacing | `fluid.css` / `fluid-wide.css` (`--ipal-*` variables) | PROGRAMISTA §2.5 |
@@ -939,6 +945,7 @@ payloadTotp } })`, never `twoFactor: false` without a client decision). CSP: fir
| Construction mode hides pages in Markdown, MCP | `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }` | `isPathVisible`, `isPathVisibleIn(mode, path)`, `pathOf(url)`, type `PathVisibility` |
| Construction mode filters the sitemap and llms.txt | `underConstructionSeo: false` | `include` / `getIncludedPaths` in the low-level builders |
| `getSettings` at `depth: 1` | — | `createContentHelpers({ settingsDepth: 2 })` (every request pays) |
| Image lightbox (off) | — (opt-in: `<SiteProviders lightbox>`, `LightboxTrigger`, `RenderRichText lightbox`, `ipalKit({ lightbox: true })` for panel labels) | `texts`, `classNames`, `unstyled`, `--ipal-lightbox-*` variables, `renderImage`, `renderDialog`, `loop`, `useLightbox`, `withLightboxUploads`, `lightboxImage` |
| `RenderRichText` renders unsafe link URLs as `#` | `safeLinks={false}` (fully trusted content only) | your own `converters` |
| Search & AI tab in Site Settings | `searchSettings: false` (top level, works without `seo`; `seo.searchSettings` still works) | `searchSettings: (fields) => fields`; `verificationFrom`, `robotsOptionsFrom` |
| Verification `<meta>` from the panel | empty fields = no tag | `const { verification, ...meta } = await generatePageMetadata(…)` |
@@ -1121,6 +1128,7 @@ Anything that needs a developer → move it to the panel.
| SEO, metadata, sitemap, JSON-LD, llms.txt | [seo.md](../seo.md) |
| Auto-slug | [slug.md](../slug.md) |
| Media: collection, file names, optimization, placeholders | [media.md](../media.md) |
| Image lightbox (enlarge, galleries, rich text images) | [lightbox.md](../lightbox.md) |
| R2, `buildImagesConfig`, YouTube | [storage.md](../storage.md) |
| Front end: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](../frontend.md) |
| Integrations (the `site-integrations` global, statuses, email test) | [integrations.md](../integrations.md) |
@@ -312,6 +312,8 @@ report WARNING "<form> outside the form renderer" "§0b — panel forms render v
# Project copies of what the plugin now ships (import instead of code)
report WARNING "own form engine" "ipal-form §3 — <RenderForm> / useBuilderForm (steps, choices, Turnstile, honeypot; Emails tab never reaches the browser)" \
"$(g 'buildValidator|useForm\(' src --include=*.tsx | grep -v 'useBuilderForm')"
report WARNING "own image lightbox" "lightbox.md — <LightboxTrigger> + lightboxImage, one <SiteProviders lightbox>; labels from Notifications → Lightbox" \
"$(g "['\"](glightbox|photoswipe|yet-another-react-lightbox|react-medium-image-zoom|fslightbox-react)['\"]" src --include=*.ts --include=*.tsx)"
report WARNING "project copy of section fields / navigation" "blocks.md, links.md — buildSectionHeaderField, buildSectionSettingsField, resolveNav (lib/content)" \
"$(ls src/fields/sectionHeader.ts src/fields/sectionSettings.ts src/lib/navigation.ts 2>/dev/null)"
if [ -n "$UI" ]; then
+4
View File
@@ -39,6 +39,10 @@ File patterns (Hero, FeatureGrid + FeatureCard): `resources/section-code.md`.
`<Section settings>` → `<SectionHeader header>` → content with `<Media>`, `<CMSLink>`,
`items.map(<Card/>)`. No text, `href`, `<img>`, hex colors or inline SVG.
3. Subcomponents go in the same folder; shared by 2+ sections → `src/components/ui/`.
An image the visitor can enlarge (gallery, card, product, certificate) → wrap the `<Media>` in
`<LightboxTrigger group={`<name>-${id}`} image={lightboxImage(item.image, { size: 'hero' })}>`
(`@intecion/ipal-kit/client`; skip the trigger when `lightboxImage` returns `null`). No
`useState` dialog, no `glightbox` — lightbox.md.
4. Add `config.ts` to `layout` in `src/collections/Pages.ts`,
and the component to `src/blocks/registry.ts` (key = slug).
5. `pnpm generate:types`.
@@ -68,6 +68,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
| `stats.collectionOverrides` | none | changes `stats-visits` like `consentLog.collectionOverrides`; its `access.read` also decides who sees the stats view and dashboard chart | object or function |
| `stats.retentionDays` / `timeZone` / `dashboard` | 90 / `'Europe/Warsaw'` / `true` | retention, day boundary, `StatsWidget` | `dashboard: false` hides the chart |
| `indexNow` | `false` | `afterChange` hook (publish → IndexNow, production + https only) in the `pages.slug ?? 'pages'` collection and each one from `content` | `true` + `indexnow-key.txt` route |
| `lightbox` | `false` | **Lightbox** group in the Notifications global (image viewer labels: open, dialog, previous, next, close, counter — localized); read by `getNotificationTexts(...).lightbox` / `getSiteShell().lightboxTexts`. Postgres: `migrate:create` | omit = English fallbacks + the `texts` prop; `lightboxNotificationFields` for your own global; `globalOverrides.notifications` |
| `siteSettingsFields` | none | **Custom** tab in Site Settings | `Field[]` |
| `integrationsFields` | none | **Custom** tab in Site Integrations | `Field[]` |
| `globalOverrides` | none | changes the plugin's globals (`site-settings`, `site-integrations`, `cookie-settings`, `notifications`): an object merges `access` / `admin` / `hooks` key by key (your keys win, your hooks run after the plugin's), other keys replace; a function `(global) => global` takes over | e.g. `{ notifications: { access: { update: authenticated } } }`; the way to change the plugin globals' access or hooks |
@@ -142,6 +143,7 @@ Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ip
| Pages | `src/collections/Pages.ts` | `buildSlugField({ from: 'title' })`, `buildNoindexField()`, `buildSummaryField()`, `slugHistory` field + `trackSlugHistoryHook`, `buildRevalidateHook({ revalidatePath, config })` → `afterChange`/`afterDelete` | edit in the panel → the page refreshes without a deploy | slug.md, hooks.md, seo.md |
| Pages — protection | as above | `beforeDelete: [buildPreventDeleteSystemPage({ settingsSlug: 'site-settings' })]`; `setPublishedAtHook`, `buildCrossLocaleFieldSync(...)` as needed | delete the homepage → error | hooks.md |
| Media | `src/collections/Media.ts` | `upload: { focalPoint: true }`, `hooks.beforeOperation: [normalizeFilenameHook, buildOptimizeUploadHook(), buildMediaPlaceholderHook()]`, fields `buildOptimizeUploadField()`, `buildMediaPlaceholderField()`, `alt` | upload `Zdjęcie Ś.JPG` → `zdjecie-s.jpg`, placeholder in the document | media.md |
| image lightbox (optional) | layout + blocks | `lightbox: true` in `ipalKit`; `<SiteProviders shell lightbox>`; `<LightboxTrigger group image={lightboxImage(media, { size: 'hero' })}>` around the thumbnail (`/client`); `<RenderRichText lightbox>` | keyboard: Tab to a thumbnail, Enter → dialog with focus on Close, ←/→, Esc → focus back; Network: a resized file on a phone | lightbox.md |
| image on the frontend | `Media` primitive | `<Image {...mediaImageProps(media, { sizes })} />`, video `videoProps` | blur before load | media.md |
| storage | `payload.config.ts` | `buildR2Storage(['media'], { s3Storage })` — always (without `R2_*` = local disk) | upload → URL from `R2_PUBLIC_URL` | storage.md |
| e-mail | `payload.config.ts` | `email: mailAdapter()` (SMTP from the panel / Graph from env; also `panelSmtpAdapter`, `graphAdapter`, `sendEmail` from `/server`) | Site Integrations → SMTP → **Send test** | email.md |
@@ -194,11 +194,11 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
| `createPageRoute(content, { blocks, notFound, permanentRedirect, redirect?, … })` | `@intecion/ipal-kit/rsc` | ready `[[...slug]]` catch-all page → `{ Page, generateMetadata, generateStaticParams }` (blocks, slug history redirects, JSON-LD, under-construction mode); does not paginate `?page=` |
| `createNotFoundPage(content, { load } \| { blocks, fallback?, … })` | `@intecion/ipal-kit/rsc` | default export of `not-found.tsx` — the 404 page chosen in the panel or a fallback (the lazy `load` variant is recommended) |
| `renderNotFoundView(content, { blocks, fallback?, blockProps?, layoutField? }, locale)` | `@intecion/ipal-kit/rsc` | 404 content in one language — called from a server action for the lazy `createNotFoundPage({ load })` (pages.md) |
| `SiteProviders` | `@intecion/ipal-kit/rsc` | layout component: `shell={await getSiteShell(locale)}` mounts consent, cookie banner, analytics, Turnstile, site JSON-LD, theme script; does not mount `AlternateLinksProvider` |
| `SiteProviders` | `@intecion/ipal-kit/rsc` | layout component: `shell={await getSiteShell(locale)}` mounts consent, cookie banner, analytics, Turnstile, site JSON-LD, theme script (and `lightbox` → `LightboxProvider`); does not mount `AlternateLinksProvider` |
Full option lists of `createContentHelpers` / `createPageRoute` / `SiteProviders` and the returned `@/lib/content` keys: `node_modules/@intecion/ipal-kit/docs/frontend.md`.
**Types:** `ContentHelpers` — `createContentHelpers` result; `SiteShell` — layout data from `getSiteShell` (consent, analytics, theme, jsonLd, settings, formTexts, turnstileSiteKey); `PageJsonLdOptions`, `EntryJsonLdContext` — `getPageJsonLd` options / your own JSON-LD nodes for entries (root); `PageRouteOptions`, `NotFoundPageOptions`, `NotFoundViewOptions`, `SiteProvidersProps` (`/rsc`) — options of `createPageRoute`, `createNotFoundPage`, `renderNotFoundView` and `SiteProviders` props.
**Types:** `ContentHelpers` — `createContentHelpers` result; `SiteShell` — layout data from `getSiteShell` (consent, analytics, theme, jsonLd, settings, formTexts, lightboxTexts, turnstileSiteKey); `PageJsonLdOptions`, `EntryJsonLdContext` — `getPageJsonLd` options / your own JSON-LD nodes for entries (root); `PageRouteOptions`, `NotFoundPageOptions`, `NotFoundViewOptions`, `SiteProvidersProps` (`/rsc`) — options of `createPageRoute`, `createNotFoundPage`, `renderNotFoundView` and `SiteProviders` props.
## Health check (`health`) — details: `node_modules/@intecion/ipal-kit/docs/deployment.md`
@@ -355,6 +355,23 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
|---|---|---|
| `createMcpRoute({ getCachedPayload, config, baseUrl?, serverName?, … })` | `@intecion/ipal-kit` | Read-only MCP server for the site (JSON-RPC: `get_site_info`, `list_pages`, `search_content`, `get_page`) as a route handler → `{ GET, POST }` in `app/api/mcp/route.ts`; with a per-IP rate limit. Usually through `mcpGET`/`mcpPOST` from `lib/content` |
## Image lightbox (`lightbox`) — details: `node_modules/@intecion/ipal-kit/docs/lightbox.md`
| Export | Import from | What it does / when |
|---|---|---|
| `LightboxProvider({ texts?, classNames?, icons?, loop?, unstyled?, renderImage?, renderDialog? })` | `@intecion/ipal-kit/client` | One shared viewer for the site (or `<SiteProviders lightbox>`); renders nothing until an image is opened |
| `LightboxTrigger({ image, group?, children, className?, style?, unstyled?, texts?, 'aria-label'? })` | `@intecion/ipal-kit/client` | `<button>` around any thumbnail that opens the large image; same `group` = one gallery in page order; works without a provider (own viewer) |
| `useLightbox()` / `useOptionalLightbox()` | `@intecion/ipal-kit/client` | `open(images, index, returnFocus)`, `openGroup(group, start)`, `next`, `previous`, `close`, `isOpen`, `index`, `images`, `texts` — for your own controls; the optional one returns `null` outside a provider |
| `LightboxDialog({ images, index, onClose, onIndexChange, … })` | `@intecion/ipal-kit/client` | The viewer itself, controlled (dialog role, focus trap and return, Esc, arrows, Home/End, swipe, counter, caption, scroll lock, reduced motion) |
| `lightboxImage(media, { size?, sizes?, srcSet?, alt?, caption? })` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | Payload media doc → `LightboxImage` (`src` from `size`, `srcSet` from every Payload size + original, alt, caption) or `null` (video, PDF, id) |
| `withLightboxUploads(converters?, { group?, image?, triggerClassName? })` | `@intecion/ipal-kit/rsc` | Wraps rich text image uploads in `LightboxTrigger` on top of your converters (`RenderRichText lightbox` uses it) |
| `LIGHTBOX_FALLBACK`, `resolveLightboxTexts(texts)` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | English labels; partial texts → full set (empty → fallback) |
| `lightboxIndex(index, delta, total, loop?)`, `formatLightboxCounter(template, current, total)` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | Wrap / clamp a gallery index; "{current} / {total}" → "2 / 5" |
| `prefersReducedMotion()` | `@intecion/ipal-kit/client` | OS reduced motion or the AccessibilityWidget switch (`data-a11y-motion="reduce"`) |
| `lightboxNotificationFields` | `@intecion/ipal-kit` | The Notifications → Lightbox field group (added by `ipalKit({ lightbox: true })`) — to place in your own global |
**Types:** `LightboxImage`, `LightboxTexts`, `LightboxClassNames`, `LightboxRenderImage`, `LightboxImageOptions` (root and `/client`); `LightboxApi`, `LightboxProviderProps`, `LightboxTriggerProps`, `LightboxDialogProps` (`/client`); `RichTextLightboxOptions` (`/rsc`). Styling: `--ipal-lightbox-*` CSS variables, `data-ipal="lightbox…"` hooks.
## Media (`media`) — details: `node_modules/@intecion/ipal-kit/docs/media.md`
| Export | Import from | What it does / when |
@@ -379,7 +396,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
| `resolveFormMessage(result, texts)` | `@intecion/ipal-kit` | `SubmitFormResult` code → text from the panel (`{field}` filled in for `validation`, `error` without exception details); `createSubmitAction` calls it itself |
| `NOTIFICATION_FALLBACK` | `@intecion/ipal-kit` | Constant: built-in English `form.*` texts used when a panel field is empty |
**Types:** `NotificationTexts`, `FormNotificationTexts` — resolved notification texts (`form` group).
**Types:** `NotificationTexts`, `FormNotificationTexts` — resolved notification texts (`form` group; `lightbox` group = `LightboxTexts`, see Image lightbox).
## System pages (`pages`) — details: `node_modules/@intecion/ipal-kit/docs/pages.md`
@@ -410,7 +427,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
| Export | Import from | What it does / when |
|---|---|---|
| `RenderRichText({ data, converters?, className?, headingIds?, safeLinks? })` | `@intecion/ipal-kit/rsc` | Renders a richText (Lexical) field through Payload's official converter; your own classes via `converters`, `headingIds` adds anchors to headings (the same ids as `extractHeadings`). Unsafe link URLs (`javascript:`, `data:`…) render as `#`; `safeLinks={false}` turns that off (fully trusted content only). Instead of a hand-written renderer. |
| `RenderRichText({ data, converters?, className?, headingIds?, lightbox?, safeLinks? })` | `@intecion/ipal-kit/rsc` | Renders a richText (Lexical) field through Payload's official converter; `lightbox` = click-to-enlarge images (lightbox.md); your own classes via `converters`, `headingIds` adds anchors to headings (the same ids as `extractHeadings`). Unsafe link URLs (`javascript:`, `data:`…) render as `#`; `safeLinks={false}` turns that off (fully trusted content only). Instead of a hand-written renderer. |
| `extractHeadings(data, { levels? })` | `@intecion/ipal-kit`, `@intecion/ipal-kit/rsc` | List of headings `{ id, level, text }` (h2 by default) for a table of contents — ids match `RenderRichText headingIds`. |
| `headingText(node)` | `@intecion/ipal-kit` | Plain text of a Lexical node (a heading with bold, links…). |
| `buildTableOfContentsField({ name? })` | `@intecion/ipal-kit` | `tableOfContents` group field (show + localized label) for a text block/section — table of contents toggle in the panel. |
+5
View File
@@ -55,6 +55,11 @@ between phases. Before each phase, go through the "Anticipate" table in AGENT.md
Order: Hero → recurring sections (FeatureGrid, CTA, FAQ…) → specific ones.
Every block: schema from the field dictionary, composition of primitives, zero text in JSX
(`ipal-audit --quick` after every block — fix errors right away).
**Enlarged images** (gallery, cards, product photos, certificates, rich text): the shared lightbox,
never a hand-made modal or a lightbox library — `ipalKit({ lightbox: true })` + migration,
`<SiteProviders lightbox>` once, `<LightboxTrigger group={`gallery-${id}`} image={lightboxImage(media, { size })}>`
around the thumbnail, `RenderRichText lightbox` for article images, Notifications → Lightbox labels
in every language (lightbox.md). Check with the keyboard: Enter opens, ←/→ browse, Esc returns focus.
## Phase 5 — Forms → **ipal-form**
Every form = a seed from `ipal-form/resources/seed-form.template.ts` (fields, confirmation, email to the
+1
View File
@@ -645,6 +645,7 @@ Do one item at a time, build, check. Order by importance:
| 45 | **1.11.1** — format description in a form field label / time as text | the **Placeholder** field in the admin panel, the **Time** type; Postgres: `migrate:create` | forms.md |
| 46 | **1.12.3** — own cookie settings window / cookie list in the banner written in the project | `<CookieBanner settings="detailed">` (list from Cookie Settings → Cookies, captions: Detail labels); delete your own version; Postgres: `migrate:create` | consent.md |
| 47 | **1.13.0** — staff access, Search & AI, seed scripts, workarounds around plugin globals | without `access`: every logged-in account gets the staff features → `access` or `globalOverrides` / `formOverrides` / `formSubmissionOverrides` / `collectionOverrides`; with `access`: staff need `editor`/`admin`; Postgres: `migrate:create`; check `settingsDepth`, `sitemap()` throwing, 2FA slug, client IP; own seed code → `@intecion/ipal-kit/seed`; global hooks/access plugins → `revalidatePath` / `globalOverrides` | CHANGELOG 1.13.0, AGENT.md §7.1, seo.md, seeding.md |
| 48 | **image lightbox** (release after 1.13.0) — own image modal (`useState(index)` + `div role="dialog"`), `glightbox` / other lightbox library, thumbnails linking to the raw file in a new tab | `ipalKit({ lightbox: true })` + Postgres `migrate:create`; `<SiteProviders lightbox>`; `<LightboxTrigger group image={lightboxImage(media, { size })}>` around the thumbnail; delete the old dialog and `pnpm remove glightbox`; old label fields → Notifications → Lightbox | lightbox.md → "Replacing a hand-made modal" |
After updating the package: `pnpm ipal:skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
`node_modules/@intecion/ipal-kit/dist`.
+3 -1
View File
@@ -145,7 +145,7 @@ import { getSiteShell } from '@/lib/content'
```
Renders: `<ThemeScript>` (when `theme`), `<MediaPreconnect>`, `<JsonLdGraph>` (site JSON-LD + `jsonLd`),
`<ConsentProvider>` with `<TurnstileProvider>`, `<CookieBanner>`, `<CookieButton>`, `<Analytics>`, `<PageStats>`.
`<ConsentProvider>` with `<TurnstileProvider>` (and `<LightboxProvider>` when `lightbox`), `<CookieBanner>`, `<CookieButton>`, `<Analytics>`, `<PageStats>`.
It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you use `LanguageSwitcher`.
| Prop | Default | What it does |
@@ -157,6 +157,7 @@ It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you
| `analytics` | on | extra `<Analytics>` props or `false` = no tags |
| `cookieMap` | — | extra cookies per category to clean up after consent is withdrawn |
| `jsonLd` | `[]` | extra JSON-LD nodes |
| `lightbox` | off | `true` / `{ texts, classNames, icons, loop, unstyled }` → one `<LightboxProvider>` for the site; texts from `shell.lightboxTexts` (Notifications → Lightbox) — lightbox.md |
| `preconnect` | `true` | `<link rel=preconnect>` to the media origin |
| `stats` | off | `true`/props → `<PageStats>` (stats.md) |
| `theme` | `false` | `<ThemeScript>` before the first paint (theme.md) |
@@ -168,6 +169,7 @@ It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you
- Any key from `createContentHelpers` can be left out of the destructuring or replaced with your own function
of the same name in `src/lib/content.ts` (e.g. your own `generateStaticParams` with entries).
- `createPageRoute`: your own view through `render`, your own 404/redirect through `onMissing`, extra block props through `blockProps`, JSON-LD through `jsonLd`.
- `SiteProviders`: `lightbox` is off by default; for `renderImage` / `renderDialog` (functions) mount `<LightboxProvider>` yourself in a client component instead (lightbox.md).
- `SiteProviders`: `banner`, `cookieButton`, `analytics` accept your own element or `false`; `analytics={{ consentMode: 'basic' }}` = no request to Google before consent (default `'advanced'`: the tag loads with every signal `denied`).
- Search & AI from the panel: `robots` instead of `getRobots` ignores it; your own robots: `buildRobots({ ...robotsOptionsFrom(settings), … })`; drop the verification tags: `const { verification, ...meta } = await generatePageMetadata(…)`.
- Construction filter in Markdown / MCP: `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }`; in the sitemap and llms.txt: `underConstructionSeo: false`.
+215
View File
@@ -0,0 +1,215 @@
# Image lightbox
One shared viewer for images that appear small — a card, a gallery grid, a product thumbnail, an
image inside rich text. The visitor clicks the thumbnail and sees the large version; images in the
same group browse with arrows, keys and swipe. Optional: nothing renders and nothing is added to the
schema until you use it.
- `<LightboxProvider>` (`/client`) — one per layout; owns the viewer.
- `<LightboxTrigger>` (`/client`) — a `<button>` around any thumbnail (`next/image`, `<img>`, your
`<Media>`). Works without a provider too (brings its own viewer).
- `lightboxImage(media, options)` (main entry and `/client`) — a Payload media doc → the large image,
with a `srcSet` from every Payload image size.
- `RenderRichText lightbox` (`/rsc`) — click-to-enlarge for images in rich text.
- `useLightbox()` (`/client`) — open, close, next, previous for your own controls.
- `<LightboxDialog>` (`/client`) — the viewer itself, controlled, for full control.
## What the visitor gets
- A full-screen dialog over the page (portal to `<body>`): `role="dialog"`, `aria-modal`, a name from
the texts, the caption linked with `aria-describedby`.
- Focus moves to Close, Tab and Shift+Tab stay inside the dialog, focus returns to the trigger on close.
- Esc closes, ← / → browse, Home / End jump to the first / last image; a click outside the image closes.
- Swipe left / right on touch screens (40 px threshold; vertical scrolling and pinch-zoom still work).
- Visible controls (44 px targets, the browser's focus ring kept), a live "2 / 5" counter, an
optional caption.
- The page does not scroll behind the dialog (scrollbar gap compensated).
- No animation when the visitor asked for reduced motion — the OS setting or the plugin's
AccessibilityWidget (`data-a11y-motion="reduce"`).
- The neighbouring images preload, so the next arrow press is instant.
- The browser picks the right file from `srcSet` (a phone does not download the 4K original).
## Setup
### 1. One provider for the site
```tsx
// app/(frontend)/[locale]/layout.tsx — Server Component
import { getNotificationTexts } from '@intecion/ipal-kit'
import { SiteProviders } from '@intecion/ipal-kit/rsc'
const payload = await getCachedPayload()
const { lightbox } = await getNotificationTexts({ payload, locale })
<SiteProviders shell={shell} lightbox={{ texts: lightbox }}>…</SiteProviders>
```
Without `SiteProviders`, mount it yourself: `<LightboxProvider texts={lightbox}>` from `/client`.
The provider renders nothing until an image is opened.
### 2. Labels in every language (the plugin's i18n)
```ts
// payload.config.ts
ipalKit({ …, lightbox: true })
```
Adds the **Lightbox** group to **Settings → Notifications**: trigger name ("Enlarge image"), dialog
name ("Image viewer"), Previous, Next, Close and the counter (`{current} / {total}`) — localized per
language. `getNotificationTexts(...).lightbox` reads them; an empty field falls back to English
(`LIGHTBOX_FALLBACK`). On Postgres this adds columns: run `pnpm payload migrate:create` and commit the
migration (Coolify runs `migrate` on deploy). Fill the labels in every language, or seed them.
Without `lightbox: true` the components still work: they use the `texts` you pass and English for the
rest. The field group is exported (`lightboxNotificationFields`) if you prefer it in your own global.
### 3. Wrap thumbnails
```tsx
import { lightboxImage, LightboxTrigger } from '@intecion/ipal-kit/client'
import { MEDIA_SIZES, mediaImageProps } from '@intecion/ipal-kit'
import Image from 'next/image'
// a gallery block — every image in one group, browsed in page order
{images.map(({ id, image }) => {
const thumb = mediaImageProps(image, { sizes: MEDIA_SIZES.third })
const large = lightboxImage(image, { size: 'hero' })
if (!thumb || !large) return null
return (
<LightboxTrigger key={id} group={`gallery-${blockId}`} image={large} className="group block overflow-hidden rounded-lg">
<Image {...thumb} className="transition group-hover:scale-105" />
</LightboxTrigger>
)
})}
```
- `group` — triggers with the same group form one gallery, in page order (whatever order they
mounted in). One group per block (`gallery-${id}`) keeps two galleries apart. No group = that image
alone.
- `image` — plain data (`{ src, srcSet?, sizes?, width?, height?, alt, caption? }`), so a Server
Component can render the trigger. `lightboxImage` builds it from a Payload doc; any other source works.
- `children` — the thumbnail, rendered as you like. With `next/image` `fill`, give the trigger a size
(`className="relative aspect-[4/3]"`).
- The button's accessible name is `texts.open + ": " + alt` ("Enlarge image: Red sofa"); pass
`aria-label` to change it.
### 4. Rich text images (opt-in)
```tsx
<RenderRichText data={post.content} lightbox />
<RenderRichText data={post.content} lightbox={{ group: 'post', image: { size: 'hero' }, triggerClassName: 'my-8' }} />
```
Every image upload becomes a trigger; PDFs and videos are left alone. Your own `upload` converter
still renders the inline image — the plugin only wraps what it returns. Default group: `'richtext'`
(every rich text on the page is one gallery); `group: false` opens each image alone. A caption or alt
from the upload node's fields wins over the document's. For your own renderer:
`converters={withLightboxUploads(myConverters, options)}` (`/rsc`).
### 5. Your own controls
```tsx
'use client'
import { useLightbox } from '@intecion/ipal-kit/client'
const box = useLightbox()
<button onClick={(e) => box.open(images, 0, e.currentTarget)}>{labels.viewAll}</button>
// box.openGroup('gallery-1', 2) · box.next() · box.previous() · box.close() · box.isOpen · box.index
```
A product page with a stage image: the stage can be the trigger, and the thumbnail strip keeps
choosing the stage image — `box.open(productImages, activeIndex, e.currentTarget)`.
## Media sizes
`lightboxImage(media, { size?, sizes?, srcSet?, alt?, caption? })`:
| option | default | effect |
|---|---|---|
| `size` | original file | the Payload image size used as `src` (fallback when the browser ignores `srcSet`), e.g. `'hero'` |
| `srcSet` | `true` | every generated size + the original as `url 768w, …`; `false` = `src` only |
| `sizes` | `'100vw'` | `sizes` of the large image |
| `alt` | the doc's `alt` | override |
| `caption` | the doc's `caption` when it is a string | override; `false` = none |
Returns `null` for a video, PDF or unpopulated id — render the thumbnail without a trigger.
A collection without `imageSizes` still works: the original file is the large image. For a phone-
friendly viewer add at least one large size (e.g. `hero` 1920 wide) to the Media collection.
## Styling
Out of the box the viewer is styled inline from CSS variables — override them on `:root` or any parent:
| variable | default |
|---|---|
| `--ipal-lightbox-backdrop` | `rgb(0 0 0 / 0.9)` |
| `--ipal-lightbox-color` | `#fff` |
| `--ipal-lightbox-padding` | `4rem 1rem` |
| `--ipal-lightbox-z-index` | `1000` |
| `--ipal-lightbox-image-max-height` | `calc(100dvh - 9rem)` |
| `--ipal-lightbox-control-bg` | `rgb(255 255 255 / 0.14)` |
| `--ipal-lightbox-control-color` | `inherit` |
| `--ipal-lightbox-control-size` | `2.75rem` |
| `--ipal-lightbox-control-radius` | `999px` |
| `--ipal-lightbox-inset` | `1rem` |
| `--ipal-lightbox-caption-color` | `inherit` |
| `--ipal-lightbox-caption-size` | `0.95rem` |
| `--ipal-lightbox-duration` | `200ms` (fade; none with reduced motion) |
```css
:root { --ipal-lightbox-backdrop: rgb(15 23 42 / 0.95); --ipal-lightbox-control-bg: var(--color-brand); }
```
Full control: `unstyled` (on the provider — applies to triggers too — or on one trigger / dialog)
drops every inline style; style with `classNames` (`dialog`, `figure`, `image`, `caption`, `counter`,
`button`, `close`, `previous`, `next`) and the `data-ipal` hooks: `lightbox`, `lightbox-backdrop`,
`lightbox-figure`, `lightbox-caption`, `lightbox-counter`, `lightbox-previous`, `lightbox-next`,
`lightbox-close`, `lightbox-trigger` (+ `data-group`). Icons: `icons={{ close, previous, next }}`.
## Turn off, override, extend
| Feature | Default | Turn off / override |
|---|---|---|
| Whole feature | off — nothing renders without a trigger | don't use the components |
| Notifications → Lightbox labels | off | `ipalKit({ lightbox: true })`; `lightboxNotificationFields` for your own global; `globalOverrides.notifications` |
| Texts | panel → `LIGHTBOX_FALLBACK` (English) | `texts` on the provider / trigger / dialog; `resolveLightboxTexts` |
| Provider in `SiteProviders` | off | `lightbox` prop; or your own `<LightboxProvider>` in a client component |
| Large image markup | `<img srcSet>` | `renderImage={({ image, imgProps, index }) => <Image … />}` (provider, client only) |
| The whole viewer | `LightboxDialog` | `renderDialog={(props) => <MyViewer {...props} />}` — same props, your markup |
| Wrap-around | on | `loop={false}` |
| Swipe threshold | 40 px | `swipeThreshold` on `LightboxDialog` |
| Rich text | off | `RenderRichText lightbox`; `withLightboxUploads(converters, options)` |
| Look | inline styles from `--ipal-lightbox-*` | CSS variables; `unstyled` + `classNames` + `data-ipal` |
Building blocks: `lightboxImage`, `lightboxIndex` (wrap / clamp), `formatLightboxCounter`,
`resolveLightboxTexts`, `LIGHTBOX_FALLBACK`, `prefersReducedMotion`, `useOptionalLightbox` (null
outside a provider), `useLightbox`, `LightboxDialog`.
## Replacing a hand-made modal (migration)
Projects built before this feature open images in different ways: a `glightbox` wrapper, an inline
`div role="dialog"` with `next/image fill`, a link to the raw file in a new tab, or nothing. Move them
to the shared lightbox:
1. **Config:** `ipalKit({ lightbox: true })`, then `pnpm payload migrate:create` (Postgres) and commit
the migration. Fill **Settings → Notifications → Lightbox** in every language — copy the labels
from the old block fields (e.g. `closeLabel`, `prevLabel`, `nextLabel`) or seed them.
2. **Layout:** `<SiteProviders lightbox={{ texts: (await getNotificationTexts({ payload, locale })).lightbox }}>`.
3. **Gallery block:** replace the clickable `<div>` / custom `<button>` + `useState(index)` + dialog
with `<LightboxTrigger group={`gallery-${id}`} image={lightboxImage(image, { size: 'hero' })!}>`
around the existing thumbnail. Delete the dialog, its keydown listener, its scroll lock and its
`useState`. Keep the thumbnail markup and its hover effect (`ZoomIn` icon overlay can stay inside
the trigger as `aria-hidden`).
4. **glightbox:** remove the wrapper, the dynamic `import('glightbox')`, its CSS and the
`glightbox` dependency (`pnpm remove glightbox`).
5. **"Open in a new tab" links** (certificates, diplomas): swap `<a href={image.url} target="_blank">`
for a `LightboxTrigger` — the visitor stays on the page.
6. **Block label fields** for close / previous / next that only served the old modal: stop reading
them; remove them in a later release with a migration (skill **ipal-migrate-fields**) once the
panel texts are filled.
7. **Check:** keyboard only — Tab to a thumbnail, Enter opens, focus is on Close, ← / → browse, Tab
stays in the dialog, Esc closes and focus is back on the thumbnail; the page does not scroll behind
the dialog; on a phone, swipe browses; DevTools → Network shows a resized file, not the original,
on a narrow screen.
Source: `src/modules/lightbox/`, `src/modules/richtext/withLightboxUploads.tsx`. Tests:
`test/lightbox.test.ts`.
+4
View File
@@ -148,5 +148,9 @@ props or `null` (video, PDF, a bare id, no `width`/`height`):
- `'background'`: `autoPlay` (off with `reducedMotion: true`), `muted`, `loop`, `preload="metadata"`;
- always `playsInline`; `poster` — a URL or a Media document.
**Enlarging an image** (card, gallery, product thumbnail): wrap the `<Media>` in `<LightboxTrigger
image={lightboxImage(resource, { size: 'hero' })}>` — `lightboxImage` builds the large image with a
`srcSet` from every Payload size. Do not build your own modal: [lightbox.md](./lightbox.md).
**`MEDIA_SIZES`** — starting points for `sizes`: `full` (`100vw`), `half`, `third`, `quarter`,
`thumb` (`160px`). You can replace any value with your own string.
+8 -2
View File
@@ -21,6 +21,12 @@ the texts in the panel (Notifications tab), grouped per context. Group `form`:
exported from `@intecion/ipal-kit`).
For forms: `getFormTexts(locale)` from `lib/content` = the `form` group in the given language.
Group `lightbox` (only with `ipalKit({ lightbox: true })` — adds columns, run a migration on Postgres):
`open` ("Enlarge image"), `dialog` ("Image viewer"), `previous`, `next`, `close`, `counter`
("{current} / {total}"). `getNotificationTexts(...).lightbox` always returns the full set (fallback
`LIGHTBOX_FALLBACK`), and `getSiteShell(locale).lightboxTexts` carries it to `<SiteProviders lightbox>`.
Details: [lightbox.md](./lightbox.md).
## Helper — getNotificationTexts
Reads the texts from the global per language, with a fallback per field. The counterpart of `getConsentTexts`:
@@ -29,7 +35,7 @@ Reads the texts from the global per language, with a fallback per field. The cou
import { getNotificationTexts } from '@intecion/ipal-kit'
const notifications = await getNotificationTexts({ payload, locale }) // in lib/content: getFormTexts(locale) = .form
// notifications.form.error, notifications.form.success, ...
// notifications.form.error, notifications.form.success, ..., notifications.lightbox.close
```
## Mapping the result — resolveFormMessage
@@ -74,7 +80,7 @@ users), so the frontend reads them without a session. Write: `editor+` (`adminOr
## Turn off, override, extend
- **Turn off:** none — the `notifications` global is currently always added (also without the `forms` option).
- **Turn off:** none — the `notifications` global is currently always added (also without the `forms` option). The `lightbox` group is opt-in (`ipalKit({ lightbox: true })`); `lightboxNotificationFields` puts it in your own global instead.
- **Override texts:** in the panel, per language; empty field → `NOTIFICATION_FALLBACK` (EN).
The fallbacks cannot be swapped with a plugin option — apply your own default texts in the project
on the result of `getNotificationTexts` (e.g. `texts.form.error ||= '…'`).
+13
View File
@@ -89,6 +89,18 @@ const items = block.tableOfContents?.show ? extractHeadings(block.content) : []
- `buildTableOfContentsField({ name = 'tableOfContents' })` — a "Show table of contents" switch + a localized label (type `TableOfContentsSettings`).
A new field in a block = a migration (`pnpm payload migrate:create`).
## Click-to-enlarge images (lightbox, opt-in)
```tsx
<RenderRichText data={post.content} lightbox />
<RenderRichText data={post.content} lightbox={{ group: 'post', image: { size: 'hero' }, triggerClassName: 'my-8' }} />
```
Each image upload is wrapped in `<LightboxTrigger>` (`/client`); the images of the page browse as one
gallery (default group `'richtext'`, `group: false` = each alone). Your own `upload` converter still
renders the inline image. Your own renderer: `converters={withLightboxUploads(myConverters, options)}`
(`/rsc`). Details, labels and styling: [lightbox.md](./lightbox.md).
## lexicalToMarkdown — richText → Markdown (for AI)
For readability by AI agents (Markdown per page, llms-full) you need
@@ -127,6 +139,7 @@ project already has (it is the editor). No extra dependencies.
- The module has no option in `ipalKit()` — it adds nothing to the schema; you use the components and functions or you don't.
- Override the look of nodes through `converters` (spread `defaultConverters`); heading ids through `headingIds` (`levels`, `className`).
- Image lightbox: off by default; `lightbox` turns it on, `withLightboxUploads` is the building block (lightbox.md).
- Link filtering: on by default; `safeLinks={false}` turns it off for fully trusted content.
- `extractHeadings(data, { levels })` and `headingText(node)` — building blocks for your own table of contents; style `<TableOfContents>` with `classNames`, the active-section threshold with `offset`.
- `lexicalToMarkdown` has no options (the handled nodes are fixed; unknown ones degrade to text) — another format needs your own converter.