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]>
24 lines
941 B
TypeScript
24 lines
941 B
TypeScript
import type { GlobalConfig } from 'payload'
|
|
|
|
import { userMeetsRole } from '../../modules/access/index.js'
|
|
import { lightboxNotificationFields, notificationsFields } from './fields.js'
|
|
|
|
/**
|
|
* Builds the Notifications global — localized action-result texts. Readable by
|
|
* any authenticated panel user; server-side helpers read it with overrideAccess
|
|
* so the frontend can resolve texts without a session. `lightbox` adds the
|
|
* image-viewer labels (ipalKit `lightbox: true`).
|
|
*/
|
|
export function buildNotifications({ lightbox = false }: { lightbox?: boolean } = {}): GlobalConfig {
|
|
return {
|
|
slug: 'notifications',
|
|
access: {
|
|
read: () => true, // texts are public-facing (shown to end users)
|
|
update: ({ req }) => userMeetsRole(req, 'editor'),
|
|
},
|
|
admin: { group: 'Settings' },
|
|
fields: lightbox ? [...notificationsFields, lightboxNotificationFields] : notificationsFields,
|
|
label: 'Notifications',
|
|
}
|
|
}
|