An open source design system that's fully customizable and agent ready
TypeScript
fix(docsite): register runnable Drawer examples (#6787)
Xinzi Zhoud80e7b7273e2
diff --git a/apps/docsite/src/__tests__/data-extraction.test.ts b/apps/docsite/src/__tests__/data-extraction.test.tsindex 2a7af6804b..697430881a 100644--- a/apps/docsite/src/__tests__/data-extraction.test.ts+++ b/apps/docsite/src/__tests__/data-extraction.test.ts@@ -4,6 +4,9 @@* @file Data extraction tests for the docsite.** Validates that the generated registries contain expected data.+ * @input Authored component docs and the generated docsite registries+ * @output Regression coverage for catalog projections, including Lab Drawer demos+ * @position Build-time docsite data verification* Run: pnpm -F @astryxdesign/docsite test*/@@ -12,6 +15,7 @@ import * as path from 'node:path';import {fileURLToPath} from 'node:url';import {describe, it, expect} from 'vitest';import {docs as chatDocs} from '../../../../packages/core/src/Chat/Chat.doc.mjs';+import {docs as drawerDocs} from '../../../../packages/lab/src/Drawer/Drawer.doc.mjs';import docsiteConfig from '../../astryx.config.mjs';import {packages} from '../generated/packageRegistry';import {@@ -1205,6 +1209,25 @@ describe('exampleRegistry', () => {expect(exampleRegistry['Dialog']).toBeDefined();});+ it('projects Drawer docs into a live showcase and five example blocks', () => {+ const drawerBlocks = blocks.filter(block => block.exampleFor === 'Drawer');+ const labels = drawerDocs.examples!.map(example => example.label);+ expect(drawerBlocks).toHaveLength(6);+ expect(drawerBlocks.map(block => block.name).sort()).toEqual(+ [...labels].sort(),+ );+ expect(+ drawerBlocks.every(block => block.sourcePackage === '@astryxdesign/lab'),+ ).toBe(true);++ const showcase = drawerBlocks.filter(block => block.isShowcase);+ expect(showcase.map(block => block.name)).toEqual([labels[0]]);+ expect(showcaseRegistry.Drawer).toBeTypeOf('function');+ expect(exampleRegistry.Drawer.map(example => example.name).sort()).toEqual(+ labels.slice(1).sort(),+ );+ });+it('Button has multiple examples', () => {const buttonExamples = exampleRegistry['Button'];expect(buttonExamples.length).toBeGreaterThanOrEqual(3);diff --git a/apps/docsite/src/__tests__/example-automaticity.test.ts b/apps/docsite/src/__tests__/example-automaticity.test.tsindex d7eb4a5cf1..93c962e6db 100644--- a/apps/docsite/src/__tests__/example-automaticity.test.ts+++ b/apps/docsite/src/__tests__/example-automaticity.test.ts@@ -8,8 +8,8 @@* `<Name>.tsx` + `<Name>.doc.mjs` pair in that root — and ZERO edits anywhere* else (no astryx.config change, no generator change, no hand-maintained* catalog). The probe uses @astryxdesign/charts, whose `templates: './blocks'`- * root already holds real blocks; Lab declares its root together with its- * first block, because `integration pack --check` rejects an empty root.+ * root already holds real blocks. A package declares its root together with+ * its first block, because `integration pack --check` rejects an empty root.** SCOPE: this file proves the DISCOVERY seam only — it writes a temporary* fixture pair into packages/charts/blocks and asserts the exact CLI API calldiff --git a/apps/docsite/src/__tests__/example-coverage.test.ts b/apps/docsite/src/__tests__/example-coverage.test.tsindex 85637e3a08..84d9fafe94 100644--- a/apps/docsite/src/__tests__/example-coverage.test.ts+++ b/apps/docsite/src/__tests__/example-coverage.test.ts@@ -104,9 +104,7 @@ describe('example coverage (report-only)', () => {// packages/lab/blocks that never reaches blockRegistry would be a silent// drop in the plumbing (as opposed to an authoring choice, which the// report above covers). Lab currently has no broken descriptors, so every- // authored block must appear, attributed to the package. With no Lab- // blocks authored yet this loop is vacuous; it becomes the admission- // regression as soon as the first block lands.+ // authored block must appear, attributed to the package.const lab = await inventoryIntegration('@astryxdesign/lab');const registeredLabNames = new Set(registeredBlocksdiff --git a/apps/docsite/src/__tests__/integration-targets.test.ts b/apps/docsite/src/__tests__/integration-targets.test.tsindex 0345ea4d90..cf82bbb924 100644--- a/apps/docsite/src/__tests__/integration-targets.test.ts+++ b/apps/docsite/src/__tests__/integration-targets.test.ts@@ -108,10 +108,11 @@ describe('production-exclusion invariants (asserted on canary artifacts)', () =>it('documents @astryxdesign/lab on canary (presence proof for the exclusion tests)', () => {// The latest-target run proves absence; this proves the same pipeline- // genuinely admits Lab components on canary, so the absence is exclusion,- // not a silently empty catalog. Lab block admission is covered generically- // once a Lab block is authored; this setup change does not add one.+ // genuinely admits Lab components and blocks on canary, so the absence is+ // exclusion, not a silently empty catalog.expect(Object.keys(components)).toContain('@astryxdesign/lab');- expect(blocks.some(block => block.sourcePackage != null)).toBe(true);+ expect(+ blocks.some(block => block.sourcePackage === '@astryxdesign/lab'),+ ).toBe(true);});});diff --git a/internal/shadcn-registry/routes.lock.json b/internal/shadcn-registry/routes.lock.jsonindex a3226ed937..d67812b7fc 100644--- a/internal/shadcn-registry/routes.lock.json+++ b/internal/shadcn-registry/routes.lock.json@@ -1980,6 +1980,31 @@"path": "examples/divider/vertical","aliases": []},+ {+ "name": "example-drawer-mobile-the-56px-page-reveal-default",+ "path": "examples/drawer/mobile-the-56px-page-reveal-default",+ "aliases": []+ },+ {+ "name": "example-drawer-modal-or-non-modal-has-scrim",+ "path": "examples/drawer/modal-or-non-modal-has-scrim",+ "aliases": []+ },+ {+ "name": "example-drawer-slide-in-from-the-start-edge",+ "path": "examples/drawer/slide-in-from-the-start-edge",+ "aliases": []+ },+ {+ "name": "example-drawer-wide-desktop-panel-full-width-on-mobile",+ "path": "examples/drawer/wide-desktop-panel-full-width-on-mobile",+ "aliases": []+ },+ {+ "name": "example-drawer-width-budget-pixels-or-any-css-length",+ "path": "examples/drawer/width-budget-pixels-or-any-css-length",+ "aliases": []+ },{"name": "example-dropdown-menu-item-basic","path": "examples/dropdown-menu-item/basic",@@ -4200,6 +4225,11 @@"path": "showcases/divider/variants","aliases": []},+ {+ "name": "showcase-drawer-basic",+ "path": "showcases/drawer/basic",+ "aliases": []+ },{"name": "showcase-dropdown-menu-item-default","path": "showcases/dropdown-menu-item/default",diff --git a/packages/lab/README.md b/packages/lab/README.mdindex e566c6b967..3439ac152b 100644--- a/packages/lab/README.md+++ b/packages/lab/README.md@@ -59,7 +59,7 @@ Authoring is the same two-artifact flow a Core author uses; the only difference1. **Component doc** — `src/<Name>/<Name>.doc.mjs` exporting `docs` (props, usage, playground config, `examples`). Picked up automatically on canary; no registration anywhere.2. **Runnable demos** — same-stem pairs in `blocks/`: `<BlockName>.tsx` + `<BlockName>.doc.mjs` (a `TemplateDoc` stamped `type: 'block'`). Discovered automatically once this package declares the directory — nothing per-component. The docsite renders the pair as the component page's showcase/examples and the playground can import anything the package exports.-**First block only:** the pull request that adds Lab's first block also adds `templates: './blocks'` to `astryx.integration.mjs` and `"blocks"` to the `files` list in `package.json`. Declaring the root earlier would fail `astryx integration pack --check`, which rejects a declared root with no contributions. After that one-time step, a new demo is just its block pair.+This package declares that directory once: `templates: './blocks'` in `astryx.integration.mjs`, and `"blocks"` in the `files` list in `package.json`. A new demo is just its block pair.How a demo reaches a component page: **`exampleFor: '<Component>'` (or `alsoExampleFor`) is what attaches a block** — the page renders every block attributed to it, whatever the block is named. The block's `name` is the demo's display name; component-doc example `labels` are CLI-snippet headings. The two are independent mechanisms.diff --git a/packages/lab/astryx.integration.mjs b/packages/lab/astryx.integration.mjsindex a44976917a..fff99b8965 100644--- a/packages/lab/astryx.integration.mjs+++ b/packages/lab/astryx.integration.mjs@@ -1,10 +1,11 @@// Copyright (c) Meta Platforms, Inc. and affiliates./**- * Astryx CLI integration for the canary-only Lab package.+ * Astryx CLI integration for the canary-only Lab components and example blocks.* Package identity and version come from package.json.*/export default {components: './src',+ templates: './blocks',issuesUrl: 'https://github.com/facebook/astryx/issues',};diff --git a/packages/lab/blocks/DrawerFullWidthMobile.doc.mjs b/packages/lab/blocks/DrawerFullWidthMobile.doc.mjsnew file mode 100644index 0000000000..269d879d8a--- /dev/null+++ b/packages/lab/blocks/DrawerFullWidthMobile.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Wide desktop panel, full-width on mobile',+ displayName: 'Wide desktop panel, full-width on mobile',+ description:+ 'Use a 560px desktop width and isFullWidthOnMobile to fill the viewport below 640px, without the default page reveal.',+ exampleFor: 'Drawer',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Drawer', 'Button', 'Section', 'VStack', 'Heading', 'Text'],+};diff --git a/packages/lab/blocks/DrawerFullWidthMobile.tsx b/packages/lab/blocks/DrawerFullWidthMobile.tsxnew file mode 100644index 0000000000..8ab7703c3c--- /dev/null+++ b/packages/lab/blocks/DrawerFullWidthMobile.tsx@@ -0,0 +1,41 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input A wide desktop budget and isFullWidthOnMobile+ * @output A Drawer that fills the viewport on mobile+ * @position Copyable Lab Drawer example+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerFullWidthMobile() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Button label="Open wide drawer" onClick={() => setIsOpen(true)} />+ <Drawer+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ label="Wide panel"+ width={560}+ isFullWidthOnMobile>+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Wide panel</Heading>+ <Text type="body">+ A wide panel on desktop, the full viewport width on mobile.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/blocks/DrawerMobileReveal.doc.mjs b/packages/lab/blocks/DrawerMobileReveal.doc.mjsnew file mode 100644index 0000000000..1ee305a4ed--- /dev/null+++ b/packages/lab/blocks/DrawerMobileReveal.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Mobile: the 56px page reveal (default)',+ displayName: 'Mobile: the 56px page reveal (default)',+ description:+ 'Below 640px, the default drawer leaves at least 56px of the page visible while respecting its width budget. Open this example in a narrow viewport to see the reveal.',+ exampleFor: 'Drawer',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Drawer', 'Button', 'Section', 'VStack', 'Heading', 'Text'],+};diff --git a/packages/lab/blocks/DrawerMobileReveal.tsx b/packages/lab/blocks/DrawerMobileReveal.tsxnew file mode 100644index 0000000000..47ccd00d07--- /dev/null+++ b/packages/lab/blocks/DrawerMobileReveal.tsx@@ -0,0 +1,40 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input A 360px width budget and the default mobile sizing+ * @output A Drawer preserving the page reveal on narrow viewports+ * @position Copyable Lab Drawer example+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerMobileReveal() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Button label="Open mobile drawer" onClick={() => setIsOpen(true)} />+ <Drawer+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ label="Mobile reveal"+ width={360}>+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Mobile reveal</Heading>+ <Text type="body">+ The page remains visible beside the drawer on mobile.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/blocks/DrawerScrim.doc.mjs b/packages/lab/blocks/DrawerScrim.doc.mjsnew file mode 100644index 0000000000..b652b2d420--- /dev/null+++ b/packages/lab/blocks/DrawerScrim.doc.mjs@@ -0,0 +1,22 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Modal or non-modal (hasScrim)',+ displayName: 'Modal or non-modal (hasScrim)',+ description:+ 'The default modal drawer dims the page, traps focus, and closes on a scrim click. With hasScrim={false}, the drawer has no scrim or focus trap and leaves the page interactive.',+ exampleFor: 'Drawer',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: [+ 'Drawer',+ 'Button',+ 'Section',+ 'HStack',+ 'VStack',+ 'Heading',+ 'Text',+ ],+};diff --git a/packages/lab/blocks/DrawerScrim.tsx b/packages/lab/blocks/DrawerScrim.tsxnew file mode 100644index 0000000000..6aa79d54a7--- /dev/null+++ b/packages/lab/blocks/DrawerScrim.tsx@@ -0,0 +1,60 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input Separate controlled states for modal and non-modal drawers+ * @output A comparison of hasScrim's two presentations+ * @position Copyable Lab Drawer example+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {HStack, VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerScrim() {+ const [openModal, setOpenModal] = useState(false);+ const [openPanel, setOpenPanel] = useState(false);++ return (+ <>+ <HStack gap={2}>+ <Button label="Open modal drawer" onClick={() => setOpenModal(true)} />+ <Button+ label="Open non-modal drawer"+ onClick={() => setOpenPanel(true)}+ />+ </HStack>+ <Drawer+ isOpen={openModal}+ onOpenChange={setOpenModal}+ label="Edit details">+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Edit details</Heading>+ <Text type="body">+ The scrim blocks the page behind this modal drawer.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ <Drawer+ isOpen={openPanel}+ onOpenChange={setOpenPanel}+ label="Inspector"+ hasScrim={false}>+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Inspector</Heading>+ <Text type="body">+ The page behind this non-modal drawer stays interactive.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/blocks/DrawerShowcase.doc.mjs b/packages/lab/blocks/DrawerShowcase.doc.mjsnew file mode 100644index 0000000000..22a902b18b--- /dev/null+++ b/packages/lab/blocks/DrawerShowcase.doc.mjs@@ -0,0 +1,15 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Basic',+ displayName: 'Basic',+ description:+ 'Open a modal drawer from a single trigger. The scrim dims the page; Escape, a scrim click, or the built-in close button closes it, and focus returns to the trigger.',+ exampleFor: 'Drawer',+ isReady: true,+ isShowcase: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Drawer', 'Button', 'Section', 'VStack', 'Heading', 'Text'],+};diff --git a/packages/lab/blocks/DrawerShowcase.tsx b/packages/lab/blocks/DrawerShowcase.tsxnew file mode 100644index 0000000000..cb7dd9281b--- /dev/null+++ b/packages/lab/blocks/DrawerShowcase.tsx@@ -0,0 +1,40 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input Controlled open state for a modal Drawer+ * @output A single-trigger drawer with a scrim and the built-in close button+ * @position Lab Drawer's docsite showcase and copyable CLI block+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerShowcase() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Button label="Open drawer" onClick={() => setIsOpen(true)} />+ <Drawer+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ label="Details"+ width={360}>+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Details</Heading>+ <Text type="body">+ Close with Escape, the scrim, or the close button.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/blocks/DrawerStart.doc.mjs b/packages/lab/blocks/DrawerStart.doc.mjsnew file mode 100644index 0000000000..fc6f40665e--- /dev/null+++ b/packages/lab/blocks/DrawerStart.doc.mjs@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Slide in from the start edge',+ displayName: 'Slide in from the start edge',+ description:+ 'Set side="start" to open from the inline start edge: left in LTR and right in RTL. The default end edge follows the inspector convention.',+ exampleFor: 'Drawer',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Drawer', 'Button', 'Section', 'VStack', 'Heading', 'Text'],+};diff --git a/packages/lab/blocks/DrawerStart.tsx b/packages/lab/blocks/DrawerStart.tsxnew file mode 100644index 0000000000..21bfb93cb9--- /dev/null+++ b/packages/lab/blocks/DrawerStart.tsx@@ -0,0 +1,40 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input Controlled open state and the logical start edge+ * @output A Drawer that opens from the start side of the viewport+ * @position Copyable Lab Drawer example+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerStart() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <>+ <Button label="Open start drawer" onClick={() => setIsOpen(true)} />+ <Drawer+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ label="Navigation"+ side="start">+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Navigation</Heading>+ <Text type="body">+ The start edge follows the page's writing direction.+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/blocks/DrawerWidths.doc.mjs b/packages/lab/blocks/DrawerWidths.doc.mjsnew file mode 100644index 0000000000..85e017951e--- /dev/null+++ b/packages/lab/blocks/DrawerWidths.doc.mjs@@ -0,0 +1,22 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */+export default {+ type: 'block',+ name: 'Width budget: pixels or any CSS length',+ displayName: 'Width budget: pixels or any CSS length',+ description:+ 'Compare a numeric pixel width with rem and percentage lengths. The width budget also caps the drawer on mobile.',+ exampleFor: 'Drawer',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: [+ 'Drawer',+ 'Button',+ 'Section',+ 'HStack',+ 'VStack',+ 'Heading',+ 'Text',+ ],+};diff --git a/packages/lab/blocks/DrawerWidths.tsx b/packages/lab/blocks/DrawerWidths.tsxnew file mode 100644index 0000000000..0c7e659514--- /dev/null+++ b/packages/lab/blocks/DrawerWidths.tsx@@ -0,0 +1,50 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @input A pixel, rem, or percentage width and controlled open state+ * @output A Drawer demonstrating the selected width budget+ * @position Copyable Lab Drawer example+ */++import {useState} from 'react';+import {Drawer} from '@astryxdesign/lab';+import {Button} from '@astryxdesign/core/Button';+import {Section} from '@astryxdesign/core/Section';+import {HStack, VStack} from '@astryxdesign/core/Stack';+import {Heading, Text} from '@astryxdesign/core/Text';++export default function DrawerWidths() {+ const [isOpen, setIsOpen] = useState(false);+ const [width, setWidth] = useState<number | string>(320);++ function openAtWidth(value: number | string) {+ setWidth(value);+ setIsOpen(true);+ }++ return (+ <>+ <HStack gap={2}>+ <Button label="320px" onClick={() => openAtWidth(320)} />+ <Button label="32rem" onClick={() => openAtWidth('32rem')} />+ <Button label="50%" onClick={() => openAtWidth('50%')} />+ </HStack>+ <Drawer+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ label="Width budget"+ width={width}>+ <Section padding={4}>+ <VStack gap={2}>+ <Heading level={3}>Width budget</Heading>+ <Text type="body">+ Width: {typeof width === 'number' ? `${width}px` : width}+ </Text>+ </VStack>+ </Section>+ </Drawer>+ </>+ );+}diff --git a/packages/lab/package.json b/packages/lab/package.jsonindex a5e4aec5c9..083c579013 100644--- a/packages/lab/package.json+++ b/packages/lab/package.json@@ -30,6 +30,7 @@"sideEffects": false,"files": ["astryx.integration.mjs",+ "blocks","dist","src","README.md",diff --git a/packages/lab/src/Drawer/Drawer.doc.mjs b/packages/lab/src/Drawer/Drawer.doc.mjsindex 7e31c6f6ad..8e83a8da7a 100644--- a/packages/lab/src/Drawer/Drawer.doc.mjs+++ b/packages/lab/src/Drawer/Drawer.doc.mjs@@ -4,7 +4,7 @@* @file Drawer.doc.mjs* @input Drawer props, panel anatomy, overlay playground config, and story-aligned examples* @output Consumer documentation and examples for Drawer- * @position CLI and rendered component documentation+ * @position CLI and docsite metadata; runnable docsite demos live in packages/lab/blocks*//** @type {import('@astryxdesign/cli/authoring').ComponentAnatomyElement[]} */@@ -198,9 +198,10 @@ export const docs = {},],},+ // CLI snippets. The docsite renders the paired Drawer blocks in ../../blocks.examples: [{- label: 'Non-modal inspector (page stays interactive)',+ label: 'Basic',code: `const [isOpen, setIsOpen] = useState(false);<><Button label="Open drawer" onClick={() => setIsOpen(true)} />@@ -208,24 +209,18 @@ export const docs = {isOpen={isOpen}onOpenChange={setIsOpen}label="Details"- hasScrim={false}width={360}><Section padding={4}><VStack gap={2}><Heading level={3}>Details</Heading>- <Text type="body">The page behind stays interactive.</Text>- <Button- label="Close"- variant="secondary"- onClick={() => setIsOpen(false)}- />+ <Text type="body">Close with Escape, the scrim, or the close button.</Text></VStack></Section></Drawer></>-// Non-modal: no scrim, no focus trap. In a real master-detail flow, derive-// the open state from the selection — isOpen={selected != null} — and clear-// the selection in onOpenChange.`,+// Modal by default: the scrim dims the page and focus is trapped. Escape, a+// scrim click, or the built-in close button closes it, and focus returns to+// the trigger.`,},{label: 'Slide in from the start edge',@@ -298,28 +293,6 @@ const [openPanel, setOpenPanel] = useState(false);</Drawer></>`,},- {- label: 'Stacked drill-in (siblings, not nested)',- code: `const [order, setOrder] = useState(null);-const [lineItem, setLineItem] = useState(null);-<>- <Drawer- isOpen={order != null}- onOpenChange={isOpen => !isOpen && setOrder(null)}- label="Order details"- hasScrim={false}>- <OrderDetails order={order} onSelectLineItem={setLineItem} />- </Drawer>- <Drawer- isOpen={lineItem != null}- onOpenChange={isOpen => !isOpen && setLineItem(null)}- label="Line item"- hasScrim={false}>- <LineItemDetails item={lineItem} />- </Drawer>-</>-// Last-opened stacks on top; Escape closes the line item first.`,- },],};diff --git a/packages/lab/tsconfig.docs.json b/packages/lab/tsconfig.docs.jsonindex f19aeb0097..13f1e12f3f 100644--- a/packages/lab/tsconfig.docs.json+++ b/packages/lab/tsconfig.docs.json@@ -6,5 +6,5 @@"checkJs": true,"noEmit": true},- "include": ["src/**/*.doc.mjs"]+ "include": ["src/**/*.doc.mjs", "blocks/**/*"]}