From 7eacf1e713c143b9194e00d04c0323180230d04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Tue, 27 Oct 2026 14:49:38 +0100 Subject: [PATCH] Docs: image lightbox page, agent guide, skills, audit check, upgrade note MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- docs/README.md | 1 + docs/agent/AGENT.md | 8 + docs/agent/skills/ipal-audit/scripts/audit.sh | 2 + docs/agent/skills/ipal-block/SKILL.md | 4 + docs/agent/skills/ipal-reference/SKILL.md | 2 + .../skills/ipal-reference/resources/api.md | 25 +- docs/agent/skills/ipal-site/SKILL.md | 5 + docs/dev/PROGRAMISTA.md | 1 + docs/frontend.md | 4 +- docs/lightbox.md | 215 ++++++++++++++++++ docs/media.md | 4 + docs/notifications.md | 10 +- docs/richtext.md | 13 ++ 13 files changed, 287 insertions(+), 7 deletions(-) create mode 100644 docs/lightbox.md diff --git a/docs/README.md b/docs/README.md index f14bf05..ea1cb7a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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) | diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index a487039..c18f6e4 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -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) — `` around the + thumbnail (a client component you render from a server block with plain `lightboxImage(…)` data), + one ``, 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 `` | `mediaImageProps`, `videoProps`, `MEDIA_SIZES` | storage.md | +| Enlarge an image (card, gallery, product, rich text) | `` + `` (`/client`), `RenderRichText lightbox`, `useLightbox`; labels: `ipalKit({ lightbox: true })` → Notifications → Lightbox | lightbox.md | | YouTube without cookies before a click | `` (`/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: ``, `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 `` 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) | diff --git a/docs/agent/skills/ipal-audit/scripts/audit.sh b/docs/agent/skills/ipal-audit/scripts/audit.sh index 4a64cc0..1fa2ba1 100644 --- a/docs/agent/skills/ipal-audit/scripts/audit.sh +++ b/docs/agent/skills/ipal-audit/scripts/audit.sh @@ -312,6 +312,8 @@ report WARNING "
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 — / 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 — + lightboxImage, one ; 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 diff --git a/docs/agent/skills/ipal-block/SKILL.md b/docs/agent/skills/ipal-block/SKILL.md index 19f705d..4b48f9e 100644 --- a/docs/agent/skills/ipal-block/SKILL.md +++ b/docs/agent/skills/ipal-block/SKILL.md @@ -39,6 +39,10 @@ File patterns (Hero, FeatureGrid + FeatureCard): `resources/section-code.md`. `
` → `` → content with ``, ``, `items.map()`. No text, `href`, ``, 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 `` in + `-${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`. diff --git a/docs/agent/skills/ipal-reference/SKILL.md b/docs/agent/skills/ipal-reference/SKILL.md index 54483a7..eb52b9f 100644 --- a/docs/agent/skills/ipal-reference/SKILL.md +++ b/docs/agent/skills/ipal-reference/SKILL.md @@ -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`; ``; `` around the thumbnail (`/client`); `` | 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 | ``, 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 | diff --git a/docs/agent/skills/ipal-reference/resources/api.md b/docs/agent/skills/ipal-reference/resources/api.md index 10b545d..d0b0054 100644 --- a/docs/agent/skills/ipal-reference/resources/api.md +++ b/docs/agent/skills/ipal-reference/resources/api.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 ``); renders nothing until an image is opened | +| `LightboxTrigger({ image, group?, children, className?, style?, unstyled?, texts?, 'aria-label'? })` | `@intecion/ipal-kit/client` | ` +// 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 `` in a client component | +| Large image markup | `` | `renderImage={({ image, imgProps, index }) => }` (provider, client only) | +| The whole viewer | `LightboxDialog` | `renderDialog={(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:** ``. +3. **Gallery block:** replace the clickable `
` / custom `