@astryxdesign/cli 0.7.2-canary.db3a2e7 → 0.7.2-canary.e2909cf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/api/component/component.test.mjs +420 -167
  2. package/api/component/list/list.mjs +42 -4
  3. package/api/integration/pack-check.mjs +10 -10
  4. package/api/search/search.mjs +8 -3
  5. package/api/search/search.test.mjs +36 -0
  6. package/api/template/template.test.mjs +120 -3
  7. package/api/theme/build/build.family.test.mjs +16 -0
  8. package/api/theme/build/build.mjs +77 -18
  9. package/api/theme/themeBuild.doc.mjs +3 -3
  10. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  11. package/assets/codemods/transforms/next/index.mjs +11 -1
  12. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  13. package/assets/docs/working-with-ai.doc.mjs +43 -4
  14. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  15. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  16. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  17. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  18. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  19. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  20. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  21. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  22. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  23. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  24. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  25. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  26. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  27. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  28. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  29. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  30. package/assets/templates/pages/detail-page/page.tsx +3 -3
  31. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  32. package/authoring/doctypes/base/type.ts +6 -0
  33. package/authoring/doctypes/component/component.doc.mjs +2 -2
  34. package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
  35. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  36. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  37. package/clients/cli/lib/component-format.mjs +5 -1
  38. package/foundation/discovery/component-discovery.d.mts +12 -0
  39. package/foundation/discovery/component-discovery.mjs +211 -0
  40. package/foundation/discovery/component-discovery.test.mjs +96 -0
  41. package/foundation/discovery/template-adapter.mjs +74 -5
  42. package/foundation/doc-compiler/doc-loads.test.mjs +5 -1
  43. package/foundation/doc-compiler/inputs.mjs +23 -0
  44. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  45. package/foundation/xle/registry.mjs +4 -0
  46. package/foundation/xle/registry.test.mjs +28 -0
  47. package/package.json +10 -10
@@ -0,0 +1,198 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Codemod: migrate List edgeCompensation to edge
5
+ *
6
+ * `edgeCompensation="inline"` on an imported `List` becomes `edge="outset"`,
7
+ * the value it already resolves to. List resolves
8
+ * `edge ?? (edgeCompensation === 'inline' ? 'outset' : 'padded')`, so `edge`
9
+ * wins only when it has a value. The deprecated prop is removed beside an
10
+ * `edge` string that no later spread can override; beside a computed `edge`,
11
+ * which may be undefined at runtime, it gets a TODO instead.
12
+ *
13
+ * Built on the shared `transformProp` helper, so it does not follow
14
+ * variables, helpers, wrappers, or types. Where a List writes
15
+ * `edgeCompensation` but the codemod cannot prove the result, it keeps the
16
+ * old prop and leaves a TODO instead of guessing: on a dynamic value, and
17
+ * wherever the List also spreads props. A spread before the old prop may
18
+ * carry an `edge` that wins today and that a new `edge` would override; one
19
+ * after it may override either prop. A spread onto a List that never writes
20
+ * `edgeCompensation` is not evidence of use, so it stays unchanged
21
+ * (`spec:AST-040` FR1): the deprecated prop keeps working through it, and
22
+ * its `@deprecated` type reports a typed use where the props are written.
23
+ * Comments are the codemod's only report channel (`api.report` is a stub),
24
+ * and each is added once, so a second run changes nothing.
25
+ */
26
+
27
+ import {transformProp} from '../../transform-prop.mjs';
28
+
29
+ export const meta = {
30
+ title: 'Migrate List edgeCompensation to edge',
31
+ description:
32
+ 'Renames `edgeCompensation="inline"` to `edge="outset"` on List, and ' +
33
+ 'drops `edgeCompensation` beside an `edge` string. Keeps the old prop ' +
34
+ 'with a TODO where `edge` is computed or a later spread may override ' +
35
+ 'it, on a dynamic value, and where the List also spreads props; the ' +
36
+ 'deprecated prop still works there.',
37
+ };
38
+
39
+ const OLD_NAME = 'edgeCompensation';
40
+ const NEW_NAME = 'edge';
41
+ const CORE_IMPORT_RE = /^@(astryxdesign|xds)\/core(?:\/|$)/;
42
+
43
+ const COMPONENT_PROPS = new Map([['List', new Set([OLD_NAME])]]);
44
+
45
+ const DYNAMIC_COMMENT =
46
+ ' TODO(astryx upgrade): edgeCompensation is deprecated. Replace ' +
47
+ 'edgeCompensation="inline" with edge="outset" by hand; this value is ' +
48
+ 'computed. ';
49
+ const BOTH_SET_COMMENT =
50
+ ' TODO(astryx upgrade): edgeCompensation is deprecated. edge is also set ' +
51
+ 'here, but it may be undefined, and then edgeCompensation still applies. ' +
52
+ 'Make edge default to "outset" where edgeCompensation is "inline", then ' +
53
+ 'remove edgeCompensation. ';
54
+ const SPREAD_COMMENT =
55
+ ' TODO(astryx upgrade): edgeCompensation is deprecated, but this List ' +
56
+ 'also spreads props that may set edge, so it was left unchanged. Replace ' +
57
+ 'edgeCompensation="inline" with edge="outset" by hand, after checking ' +
58
+ 'which edge the spread passes. ';
59
+
60
+ const TYPE_WRAPPERS = new Set([
61
+ 'TSAsExpression',
62
+ 'TSSatisfiesExpression',
63
+ 'TSTypeAssertion',
64
+ 'TSNonNullExpression',
65
+ 'TypeCastExpression',
66
+ 'ParenthesizedExpression',
67
+ ]);
68
+
69
+ /** @param {any} node */
70
+ function unwrap(node) {
71
+ let current = node;
72
+ while (current && TYPE_WRAPPERS.has(current.type)) {
73
+ current = current.expression;
74
+ }
75
+ return current;
76
+ }
77
+
78
+ /** @param {any} node */
79
+ function isStringLiteral(node) {
80
+ const value = unwrap(node);
81
+ return (
82
+ value != null &&
83
+ (value.type === 'StringLiteral' || value.type === 'Literal') &&
84
+ typeof value.value === 'string'
85
+ );
86
+ }
87
+
88
+ /**
89
+ * The value of a JSX attribute: the string of `edge="flush"`, or the
90
+ * expression inside `edge={...}`.
91
+ * @param {any} attribute
92
+ */
93
+ function attributeValue(attribute) {
94
+ return attribute.value?.type === 'JSXExpressionContainer'
95
+ ? attribute.value.expression
96
+ : attribute.value;
97
+ }
98
+
99
+ /** @param {any} node */
100
+ function isInlineLiteral(node) {
101
+ const value = unwrap(node);
102
+ return (
103
+ value != null &&
104
+ (value.type === 'StringLiteral' || value.type === 'Literal') &&
105
+ value.value === 'inline'
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Attach a comment to a node once, so re-running the codemod adds nothing.
111
+ * @param {any} j @param {any} node @param {string} text
112
+ */
113
+ function addComment(j, node, text) {
114
+ node.comments ??= [];
115
+ if (node.comments.some((/** @type {any} */ c) => c.value === text)) {
116
+ return false;
117
+ }
118
+ node.comments.push(j.commentBlock(text, true, false));
119
+ return true;
120
+ }
121
+
122
+ /** @param {any} attributes */
123
+ function firstSpread(attributes) {
124
+ return attributes.find(
125
+ (/** @type {any} */ attribute) => attribute.type === 'JSXSpreadAttribute',
126
+ );
127
+ }
128
+
129
+ /**
130
+ * @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file
131
+ * @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api
132
+ * @returns {string | null | undefined}
133
+ */
134
+ export default function transformer(file, api) {
135
+ const j = api.jscodeshift;
136
+ const root = j(file.source);
137
+ let hasChanges = false;
138
+
139
+ transformProp(
140
+ root,
141
+ j,
142
+ {
143
+ matchesImport: source => CORE_IMPORT_RE.test(source),
144
+ components: COMPONENT_PROPS,
145
+ },
146
+ propPath => {
147
+ const opening = propPath.parent?.node;
148
+ const attributes = opening?.attributes ?? [];
149
+ const prop = propPath.node;
150
+ const edgeIndex = attributes.findIndex(
151
+ (/** @type {any} */ attribute) =>
152
+ attribute.type === 'JSXAttribute' &&
153
+ attribute.name?.name === NEW_NAME,
154
+ );
155
+ if (edgeIndex !== -1) {
156
+ // `edge` wins only when it has a value. A string that no later
157
+ // spread can override always does, so the old prop is inert and
158
+ // removing it changes nothing. A computed `edge` may be undefined,
159
+ // and then the old prop still decides.
160
+ const isProven =
161
+ isStringLiteral(attributeValue(attributes[edgeIndex])) &&
162
+ !attributes
163
+ .slice(edgeIndex + 1)
164
+ .some(
165
+ (/** @type {any} */ attribute) =>
166
+ attribute.type === 'JSXSpreadAttribute',
167
+ );
168
+ if (isProven) {
169
+ opening.attributes = attributes.filter(
170
+ (/** @type {any} */ attribute) => attribute !== prop,
171
+ );
172
+ hasChanges = true;
173
+ } else {
174
+ hasChanges = addComment(j, prop, BOTH_SET_COMMENT) || hasChanges;
175
+ }
176
+ return;
177
+ }
178
+ // With a spread on the element the rename cannot be proven: a spread
179
+ // before the old prop may carry an `edge` that wins today and that a
180
+ // new `edge` would override, and one after it may override either
181
+ // prop. The old prop keeps working, so it stays, with a TODO.
182
+ if (firstSpread(attributes)) {
183
+ hasChanges = addComment(j, prop, SPREAD_COMMENT) || hasChanges;
184
+ return;
185
+ }
186
+ if (isInlineLiteral(attributeValue(prop))) {
187
+ prop.name.name = NEW_NAME;
188
+ prop.value = j.stringLiteral('outset');
189
+ hasChanges = true;
190
+ } else {
191
+ hasChanges = addComment(j, prop, DYNAMIC_COMMENT) || hasChanges;
192
+ }
193
+ },
194
+ );
195
+
196
+ if (!hasChanges) return undefined;
197
+ return root.toSource({quote: 'single'});
198
+ }
@@ -44,7 +44,7 @@ export const docs = {
44
44
  },
45
45
  {
46
46
  type: 'prose',
47
- text: 'By default this creates `AGENTS.md` (the tool-agnostic standard most agents read). To target a specific tool\'s file instead:',
47
+ text: "By default this creates `AGENTS.md` (the tool-agnostic standard most agents read). To target a specific tool's file instead:",
48
48
  },
49
49
  {
50
50
  type: 'code',
@@ -182,21 +182,60 @@ astryx docs principles --dense`,
182
182
  },
183
183
  {
184
184
  type: 'prose',
185
- text: 'Add the server to your MCP config file. This works with any MCP-compatible tool: Claude Desktop (claude_desktop_config.json), Cursor (.cursor/mcp.json), Windsurf (.windsurf/mcp.json), Cline, and others.',
185
+ text: 'Add the server to your MCP config file. The entry is a remote HTTP server, and the exact shape differs per client, so use the snippet for the tool you run. An entry with an unrecognized transport is skipped with a warning rather than an error, which reads as a server that connects but exposes no tools.',
186
186
  },
187
187
  {
188
188
  type: 'code',
189
189
  lang: 'json',
190
- label: 'MCP config (same for all tools)',
190
+ label: 'Claude Code (.mcp.json)',
191
191
  code: `{
192
192
  "mcpServers": {
193
193
  "astryx": {
194
- "type": "url",
194
+ "type": "http",
195
195
  "url": "https://astryx.atmeta.com/mcp"
196
196
  }
197
197
  }
198
198
  }`,
199
199
  },
200
+ {
201
+ type: 'prose',
202
+ text: 'Claude Code can also write that entry from the terminal:',
203
+ },
204
+ {
205
+ type: 'code',
206
+ lang: 'bash',
207
+ code: `claude mcp add --transport http astryx https://astryx.atmeta.com/mcp`,
208
+ },
209
+ {
210
+ type: 'code',
211
+ lang: 'json',
212
+ label: 'Cline (cline_mcp_settings.json) - type is streamableHttp',
213
+ code: `{
214
+ "mcpServers": {
215
+ "astryx": {
216
+ "type": "streamableHttp",
217
+ "url": "https://astryx.atmeta.com/mcp"
218
+ }
219
+ }
220
+ }`,
221
+ },
222
+ {
223
+ type: 'code',
224
+ lang: 'json',
225
+ label:
226
+ 'Cursor (.cursor/mcp.json) - remote servers take no type field',
227
+ code: `{
228
+ "mcpServers": {
229
+ "astryx": {
230
+ "url": "https://astryx.atmeta.com/mcp"
231
+ }
232
+ }
233
+ }`,
234
+ },
235
+ {
236
+ type: 'prose',
237
+ text: 'Claude Desktop is the exception: claude_desktop_config.json holds local stdio servers, so a remote server is added through Settings, then Connectors, then Add custom connector, pasting the URL above.',
238
+ },
200
239
  {
201
240
  type: 'prose',
202
241
  text: 'Once connected, your AI tool can search for components by natural language (e.g. "dropdown menu", "success message") and retrieve full documentation without any manual CLI invocation. The server uses the same keyword index from component docs, so search quality improves automatically as component documentation is updated.',
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'Edit form with footer actions',
7
+ displayName: 'Edit form with footer actions',
8
+ description:
9
+ 'Compose a Layout with DrawerHeader, the fields in LayoutContent, and Cancel and Save in a pinned LayoutFooter. purpose="form" keeps Escape but ignores scrim clicks, so a stray click outside does not discard edits.',
10
+ exampleFor: 'Drawer',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'DrawerHeader',
16
+ 'Button',
17
+ 'Layout',
18
+ 'LayoutContent',
19
+ 'LayoutFooter',
20
+ 'HStack',
21
+ 'VStack',
22
+ 'TextInput',
23
+ ],
24
+ };
@@ -0,0 +1,62 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Controlled open state and two editable fields
7
+ * @output A form drawer with a header, scrolling fields, and pinned footer
8
+ * actions; purpose="form" keeps Escape but ignores scrim clicks
9
+ * @position Copyable Drawer example
10
+ */
11
+
12
+ import {useState} from 'react';
13
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
14
+ import {Button} from '@astryxdesign/core/Button';
15
+ import {Layout, LayoutContent, LayoutFooter} from '@astryxdesign/core/Layout';
16
+ import {HStack, VStack} from '@astryxdesign/core/Stack';
17
+ import {TextInput} from '@astryxdesign/core/TextInput';
18
+
19
+ export default function DrawerForm() {
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ const [name, setName] = useState('web-prod-04');
22
+ const [owner, setOwner] = useState('Platform team');
23
+
24
+ return (
25
+ <>
26
+ <Button label="Edit host" onClick={() => setIsOpen(true)} />
27
+ <Drawer
28
+ isOpen={isOpen}
29
+ onOpenChange={setIsOpen}
30
+ label="Edit host"
31
+ purpose="form">
32
+ <Layout
33
+ header={<DrawerHeader title="Edit host" onOpenChange={setIsOpen} />}
34
+ content={
35
+ <LayoutContent>
36
+ <VStack gap={4}>
37
+ <TextInput label="Name" value={name} onChange={setName} />
38
+ <TextInput label="Owner" value={owner} onChange={setOwner} />
39
+ </VStack>
40
+ </LayoutContent>
41
+ }
42
+ footer={
43
+ <LayoutFooter>
44
+ <HStack gap={2} hAlign="end">
45
+ <Button
46
+ label="Cancel"
47
+ variant="secondary"
48
+ onClick={() => setIsOpen(false)}
49
+ />
50
+ <Button
51
+ label="Save"
52
+ variant="primary"
53
+ onClick={() => setIsOpen(false)}
54
+ />
55
+ </HStack>
56
+ </LayoutFooter>
57
+ }
58
+ />
59
+ </Drawer>
60
+ </>
61
+ );
62
+ }
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'Modal or non-modal (hasScrim)',
7
+ displayName: 'Modal or non-modal (hasScrim)',
8
+ description:
9
+ '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.',
10
+ exampleFor: 'Drawer',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'Button',
16
+ 'Layout',
17
+ 'LayoutContent',
18
+ 'HStack',
19
+ 'DrawerHeader',
20
+ 'Text',
21
+ ],
22
+ };
@@ -0,0 +1,68 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Separate controlled states for modal and non-modal drawers
7
+ * @output A comparison of hasScrim's two presentations
8
+ * @position Copyable Drawer example
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
13
+ import {Button} from '@astryxdesign/core/Button';
14
+ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
15
+ import {HStack} from '@astryxdesign/core/Stack';
16
+ import {Text} from '@astryxdesign/core/Text';
17
+
18
+ export default function DrawerScrim() {
19
+ const [openModal, setOpenModal] = useState(false);
20
+ const [openPanel, setOpenPanel] = useState(false);
21
+
22
+ return (
23
+ <>
24
+ <HStack gap={2}>
25
+ <Button label="Open modal drawer" onClick={() => setOpenModal(true)} />
26
+ <Button
27
+ label="Open non-modal drawer"
28
+ onClick={() => setOpenPanel(true)}
29
+ />
30
+ </HStack>
31
+ <Drawer
32
+ isOpen={openModal}
33
+ onOpenChange={setOpenModal}
34
+ label="Edit details">
35
+ <Layout
36
+ header={
37
+ <DrawerHeader title="Edit details" onOpenChange={setOpenModal} />
38
+ }
39
+ content={
40
+ <LayoutContent>
41
+ <Text type="body">
42
+ The scrim blocks the page behind this modal drawer.
43
+ </Text>
44
+ </LayoutContent>
45
+ }
46
+ />
47
+ </Drawer>
48
+ <Drawer
49
+ isOpen={openPanel}
50
+ onOpenChange={setOpenPanel}
51
+ label="Inspector"
52
+ hasScrim={false}>
53
+ <Layout
54
+ header={
55
+ <DrawerHeader title="Inspector" onOpenChange={setOpenPanel} />
56
+ }
57
+ content={
58
+ <LayoutContent>
59
+ <Text type="body">
60
+ The page behind this non-modal drawer stays interactive.
61
+ </Text>
62
+ </LayoutContent>
63
+ }
64
+ />
65
+ </Drawer>
66
+ </>
67
+ );
68
+ }
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'Basic',
7
+ displayName: 'Basic',
8
+ description:
9
+ 'Open a modal drawer from a single trigger. The scrim dims the page; Escape, a scrim click, or the header close button closes it, and focus returns to the trigger.',
10
+ exampleFor: 'Drawer',
11
+ isReady: true,
12
+ isShowcase: true,
13
+ aspectRatio: 16 / 9,
14
+ componentsUsed: [
15
+ 'Drawer',
16
+ 'Button',
17
+ 'Layout',
18
+ 'LayoutContent',
19
+ 'DrawerHeader',
20
+ 'Text',
21
+ ],
22
+ };
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Controlled open state for a modal Drawer
7
+ * @output A single-trigger drawer with a scrim and a DrawerHeader close button
8
+ * @position Drawer's docsite showcase and copyable CLI block
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
13
+ import {Button} from '@astryxdesign/core/Button';
14
+ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
15
+ import {Text} from '@astryxdesign/core/Text';
16
+
17
+ export default function DrawerShowcase() {
18
+ const [isOpen, setIsOpen] = useState(false);
19
+
20
+ return (
21
+ <>
22
+ <Button label="Open drawer" onClick={() => setIsOpen(true)} />
23
+ <Drawer
24
+ isOpen={isOpen}
25
+ onOpenChange={setIsOpen}
26
+ label="Details"
27
+ width={360}>
28
+ <Layout
29
+ header={<DrawerHeader title="Details" onOpenChange={setIsOpen} />}
30
+ content={
31
+ <LayoutContent>
32
+ <Text type="body">
33
+ Close with Escape, the scrim, or the close button.
34
+ </Text>
35
+ </LayoutContent>
36
+ }
37
+ />
38
+ </Drawer>
39
+ </>
40
+ );
41
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'Slide in from the start edge',
7
+ displayName: 'Slide in from the start edge',
8
+ description:
9
+ '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.',
10
+ exampleFor: 'Drawer',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'Button',
16
+ 'Layout',
17
+ 'LayoutContent',
18
+ 'DrawerHeader',
19
+ 'Text',
20
+ ],
21
+ };
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Controlled open state and the logical start edge
7
+ * @output A Drawer that opens from the start side of the viewport
8
+ * @position Copyable Drawer example
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
13
+ import {Button} from '@astryxdesign/core/Button';
14
+ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
15
+ import {Text} from '@astryxdesign/core/Text';
16
+
17
+ export default function DrawerStart() {
18
+ const [isOpen, setIsOpen] = useState(false);
19
+
20
+ return (
21
+ <>
22
+ <Button label="Open start drawer" onClick={() => setIsOpen(true)} />
23
+ <Drawer
24
+ isOpen={isOpen}
25
+ onOpenChange={setIsOpen}
26
+ label="Navigation"
27
+ side="start">
28
+ <Layout
29
+ header={<DrawerHeader title="Navigation" onOpenChange={setIsOpen} />}
30
+ content={
31
+ <LayoutContent>
32
+ <Text type="body">
33
+ The start edge follows the page's writing direction.
34
+ </Text>
35
+ </LayoutContent>
36
+ }
37
+ />
38
+ </Drawer>
39
+ </>
40
+ );
41
+ }
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'Width budget: pixels or any CSS length',
7
+ displayName: 'Width budget: pixels or any CSS length',
8
+ description:
9
+ 'Compare a numeric pixel width with rem and percentage lengths. The width budget also caps the drawer on mobile.',
10
+ exampleFor: 'Drawer',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'Button',
16
+ 'Layout',
17
+ 'LayoutContent',
18
+ 'HStack',
19
+ 'DrawerHeader',
20
+ 'Text',
21
+ ],
22
+ };
@@ -0,0 +1,54 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input A pixel, rem, or percentage width and controlled open state
7
+ * @output A Drawer demonstrating the selected width budget
8
+ * @position Copyable Drawer example
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
13
+ import {Button} from '@astryxdesign/core/Button';
14
+ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
15
+ import {HStack} from '@astryxdesign/core/Stack';
16
+ import {Text} from '@astryxdesign/core/Text';
17
+
18
+ export default function DrawerWidths() {
19
+ const [isOpen, setIsOpen] = useState(false);
20
+ const [width, setWidth] = useState<number | string>(320);
21
+
22
+ function openAtWidth(value: number | string) {
23
+ setWidth(value);
24
+ setIsOpen(true);
25
+ }
26
+
27
+ return (
28
+ <>
29
+ <HStack gap={2}>
30
+ <Button label="320px" onClick={() => openAtWidth(320)} />
31
+ <Button label="32rem" onClick={() => openAtWidth('32rem')} />
32
+ <Button label="50%" onClick={() => openAtWidth('50%')} />
33
+ </HStack>
34
+ <Drawer
35
+ isOpen={isOpen}
36
+ onOpenChange={setIsOpen}
37
+ label="Width budget"
38
+ width={width}>
39
+ <Layout
40
+ header={
41
+ <DrawerHeader title="Width budget" onOpenChange={setIsOpen} />
42
+ }
43
+ content={
44
+ <LayoutContent>
45
+ <Text type="body">
46
+ Width: {typeof width === 'number' ? `${width}px` : width}
47
+ </Text>
48
+ </LayoutContent>
49
+ }
50
+ />
51
+ </Drawer>
52
+ </>
53
+ );
54
+ }
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ name: 'DrawerHeader',
7
+ displayName: 'Drawer Header',
8
+ description:
9
+ 'DrawerHeader provides a structured header for drawers with slots for title, subtitle, close button, and optional start or end content.',
10
+ exampleFor: 'DrawerHeader',
11
+ isReady: true,
12
+ isShowcase: true,
13
+ aspectRatio: 16 / 9,
14
+ componentsUsed: ['DrawerHeader', 'Layout', 'LayoutContent', 'Text'],
15
+ };