An open source design system that's fully customizable and agent ready
TypeScript
docs: add Lightbox examples and fix playground preview (#3301)
Harshavardhan S Patil12aa8ed49ac5
diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.doc.mjs b/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.doc.mjsnew file mode 100644index 0000000000..9fe60dd00e--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ exampleFor: 'Lightbox',+ name: 'Lightbox — Gallery',+ displayName: 'Lightbox — Gallery',+ description:+ 'A thumbnail grid that opens a fullscreen gallery. Clicking any thumbnail opens the lightbox at that index. Prev/next navigation lets users browse all images without closing.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['Lightbox', 'Grid', 'Thumbnail'],+};diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.tsx b/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.tsxnew file mode 100644index 0000000000..84695631c2--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxGallery.tsx@@ -0,0 +1,53 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++import {useLightbox} from '@astryxdesign/core/Lightbox';+import {Grid} from '@astryxdesign/core/Grid';+import {Thumbnail} from '@astryxdesign/core/Thumbnail';++const PHOTOS = [+ {+ src: 'https://lookaside.facebook.com/assets/astryx/Neutral-Backpack.png',+ alt: 'Backpack',+ caption: 'A backpack displayed on a neutral background.',+ },+ {+ src: 'https://lookaside.facebook.com/assets/astryx/building.png',+ alt: 'Modern building',+ caption: 'A modern building with a contemporary architectural design.',+ },+ {+ src: 'https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png',+ alt: 'Coastal shoreline with ocean waves',+ caption:+ 'A scenic coastline with waves rolling onto a sandy beach beneath a clear sky.',+ },+ {+ src: 'https://lookaside.facebook.com/assets/astryx/illustrative-vertical-1.png',+ alt: 'Illustrated lakeside landscape at sunset',+ caption:+ 'A stylized landscape illustration featuring pink clouds reflected over a calm lake at sunset.',+ },+];++export default function LightboxGallery() {+ const lightbox = useLightbox({media: PHOTOS});++ return (+ <>+ <Grid columns={2} gap={2} style={{width: 136}}>+ {PHOTOS.map((photo, i) => (+ <Thumbnail+ key={photo.src}+ src={photo.src}+ alt={photo.alt}+ label={photo.alt}+ onClick={() => lightbox.open(i)}+ />+ ))}+ </Grid>+ {lightbox.element}+ </>+ );+}diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxShowcase.tsx b/packages/cli/templates/blocks/components/Lightbox/LightboxShowcase.tsxindex 23aa26f9f8..7ef01bdc82 100644--- a/packages/cli/templates/blocks/components/Lightbox/LightboxShowcase.tsx+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxShowcase.tsx@@ -12,9 +12,10 @@ export default function LightboxShowcase() {isOpen={isOpen}onOpenChange={setIsOpen}media={{- src: 'https://picsum.photos/id/10/1200/800',- alt: 'Forest path',- caption: 'A winding path through the forest',+ src: 'https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png',+ alt: 'Coastal shoreline with ocean waves',+ caption:+ 'A scenic coastline with waves rolling onto a sandy beach beneath a clear sky.',}}/></>diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.doc.mjs b/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.doc.mjsnew file mode 100644index 0000000000..11c21291f6--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ exampleFor: 'Lightbox',+ name: 'Lightbox — Video',+ displayName: 'Lightbox — Video',+ description:+ 'Opens a video in the lightbox. Native browser controls are available. Zoom and pan are disabled for video items.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['Lightbox'],+};diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.tsx b/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.tsxnew file mode 100644index 0000000000..9954028fc6--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxVideo.tsx@@ -0,0 +1,27 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++import {useState} from 'react';+import {Lightbox} from '@astryxdesign/core/Lightbox';+import {Button} from '@astryxdesign/core/Button';++export default function LightboxVideo() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Button label="Play video" onClick={() => setIsOpen(true)} />+ <Lightbox+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ media={{+ src: 'https://lookaside.facebook.com/assets/?set=astryx&name=Nature-1&density=1',+ alt: 'Flower blooming in time-lapse',+ type: 'video',+ caption: 'A flower blooming in time-lapse',+ }}+ />+ </>+ );+}diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.doc.mjs b/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.doc.mjsnew file mode 100644index 0000000000..91c652b0c3--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ exampleFor: 'Lightbox',+ name: 'Lightbox — Zoom',+ displayName: 'Lightbox — Zoom',+ description:+ 'A lightbox with zoom and pan enabled. Double-click the image to zoom in; drag to pan around. Double-click again or use the close button to exit.',+ isReady: true,+ aspectRatio: 4 / 3,+ componentsUsed: ['Lightbox', 'Thumbnail'],+};diff --git a/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.tsx b/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.tsxnew file mode 100644index 0000000000..282508523c--- /dev/null+++ b/packages/cli/templates/blocks/components/Lightbox/LightboxZoom.tsx@@ -0,0 +1,33 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++import {useState} from 'react';+import {Lightbox} from '@astryxdesign/core/Lightbox';+import {Thumbnail} from '@astryxdesign/core/Thumbnail';++export default function LightboxZoom() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Thumbnail+ src="https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png"+ alt="Coastal shoreline with ocean waves"+ label="Coastal shoreline with ocean waves"+ onClick={() => setIsOpen(true)}+ />+ <Lightbox+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ media={{+ src: 'https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png',+ alt: 'Coastal shoreline with ocean waves',+ caption:+ 'A scenic coastline. Double-click to zoom in and drag to pan.',+ }}+ hasZoom+ />+ </>+ );+}diff --git a/packages/core/src/Lightbox/Lightbox.doc.mjs b/packages/core/src/Lightbox/Lightbox.doc.mjsindex 5f5e970fd7..3ddfd3b370 100644--- a/packages/core/src/Lightbox/Lightbox.doc.mjs+++ b/packages/core/src/Lightbox/Lightbox.doc.mjs@@ -64,6 +64,15 @@ export const docs = {{ guidance: false, description: 'Nest interactive content inside captions; keep them plain text.' },],},+ playground: {+ defaults: {+ media: {+ src: 'https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png',+ alt: 'Coastal shoreline with ocean waves',+ caption: 'A scenic coastline with waves rolling onto a sandy beach beneath a clear sky.',+ },+ },+ },};/** @type {import('../docs-types').ComponentDoc} */