Shared image lightbox: LightboxProvider, LightboxTrigger, LightboxDialog, lightboxImage
Opt-in click-to-enlarge for small images (cards, galleries, rich text):
- /client: LightboxProvider (one viewer per site), LightboxTrigger (button
around any thumbnail, works without a provider), LightboxDialog
(controlled viewer), useLightbox / useOptionalLightbox
- accessible dialog: aria-modal, focus trap and return, Esc, arrows,
Home/End, swipe, counter, caption, scroll lock, reduced motion
- lightboxImage builds src + srcSet from Payload image sizes
- labels: ipalKit({ lightbox: true }) adds Notifications -> Lightbox;
getNotificationTexts().lightbox and getSiteShell().lightboxTexts,
English fallbacks otherwise
- RenderRichText lightbox / withLightboxUploads wrap image uploads
- SiteProviders lightbox mounts the provider
- styling from --ipal-lightbox-* variables; unstyled + classNames,
renderImage, renderDialog, icons, loop overrides
- tests with happy-dom (vitest's pinned optional peer)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e53d09b720
commit
476c3ac1df
@@ -1,5 +1,7 @@
|
||||
import type { NotificationTexts } from './types.js'
|
||||
|
||||
import { LIGHTBOX_FALLBACK } from '../lightbox/texts.js'
|
||||
|
||||
/**
|
||||
* Built-in English fallbacks, used per field when the Notifications global
|
||||
* leaves a text empty. Same philosophy as consent FALLBACK: the site works out
|
||||
@@ -18,4 +20,5 @@ export const NOTIFICATION_FALLBACK: NotificationTexts = {
|
||||
turnstile: 'Captcha verification failed. Please try again.',
|
||||
validation: 'Please check the {field} field and try again.',
|
||||
},
|
||||
lightbox: LIGHTBOX_FALLBACK,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { BasePayload } from 'payload'
|
||||
|
||||
import type { NotificationsData, NotificationTexts } from './types.js'
|
||||
|
||||
import { resolveLightboxTexts } from '../lightbox/texts.js'
|
||||
import { getGlobal } from '../payload/index.js'
|
||||
import { NOTIFICATION_FALLBACK } from './defaults.js'
|
||||
|
||||
@@ -39,5 +40,6 @@ export async function getNotificationTexts({
|
||||
turnstile: f.turnstile || fb.turnstile,
|
||||
validation: f.validation || fb.validation,
|
||||
},
|
||||
lightbox: resolveLightboxTexts(g.lightbox),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LightboxTexts } from '../lightbox/types.js'
|
||||
|
||||
/**
|
||||
* Resolved notification texts, ready for the frontend. Grouped per context;
|
||||
* `form` maps submitForm result codes to user-facing messages.
|
||||
@@ -22,9 +24,12 @@ export type FormNotificationTexts = {
|
||||
|
||||
export type NotificationTexts = {
|
||||
form: FormNotificationTexts
|
||||
/** Image viewer labels — pass to <LightboxProvider texts>. Fallbacks when ipalKit `lightbox` is off. */
|
||||
lightbox: LightboxTexts
|
||||
}
|
||||
|
||||
/** Raw shape read from the Notifications global (all fields optional). */
|
||||
export type NotificationsData = {
|
||||
form?: Partial<FormNotificationTexts>
|
||||
lightbox?: null | Partial<Record<keyof LightboxTexts, null | string>>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user