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

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 (142) hide show
  1. package/README.md +7 -7
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +41 -1
  4. package/api/component/_adapter.mjs +93 -7
  5. package/api/component/component.mjs +22 -5
  6. package/api/component/component.test.mjs +420 -167
  7. package/api/component/integration-export-name.test.mjs +644 -0
  8. package/api/component/list/list.mjs +42 -4
  9. package/api/docs/_adapter.mjs +207 -1
  10. package/api/docs/integrationDocs.test.mjs +124 -0
  11. package/api/doctor/theme-checks.mjs +1 -1
  12. package/api/gap-report/gap-report.mjs +67 -4
  13. package/api/init/run/run.mjs +2 -2
  14. package/api/integration/_adapter.d.mts +12 -0
  15. package/api/integration/_adapter.mjs +54 -0
  16. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  17. package/api/integration/add-contribution.mjs +7 -3
  18. package/api/integration/authoring-checks.mjs +11 -2
  19. package/api/integration/authoring-checks.test.mjs +39 -0
  20. package/api/integration/authoring-checks.type.d.mts +9 -0
  21. package/api/integration/authoring-checks.type.mjs +14 -1
  22. package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
  23. package/api/integration/pack-check.mjs +61 -107
  24. package/api/integration/pack-check.test.mjs +359 -0
  25. package/api/integration/validate-integration.test.mjs +11 -0
  26. package/api/search/search.d.mts +9 -0
  27. package/api/search/search.mjs +108 -16
  28. package/api/search/search.test.mjs +36 -0
  29. package/api/swizzle/copy/copy.mjs +28 -14
  30. package/api/template/template.test.mjs +120 -3
  31. package/api/theme/build/build.family.test.mjs +16 -0
  32. package/api/theme/build/build.mjs +81 -22
  33. package/api/theme/themeBuild.doc.mjs +3 -3
  34. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  35. package/assets/codemods/transforms/next/index.mjs +11 -1
  36. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  37. package/assets/docs/README.md +10 -0
  38. package/assets/docs/author-a-theme.doc.mjs +1 -1
  39. package/assets/docs/getting-started.doc.mjs +3 -3
  40. package/assets/docs/theme.doc.dense.mjs +1 -1
  41. package/assets/docs/theme.doc.mjs +1 -1
  42. package/assets/docs/theme.doc.zh.mjs +1 -1
  43. package/assets/docs/tree/add-a-component.doc.mjs +10 -0
  44. package/assets/docs/tree/check-the-props.doc.mjs +145 -0
  45. package/assets/docs/tree/checks.doc.mjs +4 -4
  46. package/assets/docs/tree/component-family.doc.mjs +5 -1
  47. package/assets/docs/tree/component-imports.doc.mjs +8 -0
  48. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  49. package/assets/docs/tree/links.doc.mjs +2 -2
  50. package/assets/docs/tree/single-component.doc.mjs +3 -2
  51. package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
  52. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  53. package/assets/docs/tree/versioning.doc.mjs +1 -0
  54. package/assets/docs/tree/write-the-template-file.doc.mjs +2 -1
  55. package/assets/docs/use-a-theme.doc.mjs +2 -2
  56. package/assets/docs/working-with-ai.doc.mjs +43 -4
  57. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  58. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  59. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  60. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  61. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  62. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  63. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  64. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  65. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  66. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  67. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  68. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  69. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  70. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  71. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  72. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  73. package/assets/templates/pages/detail-page/page.tsx +3 -3
  74. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  75. package/assets/theme.template.ts +1 -1
  76. package/authoring/doctypes/base/type.ts +6 -0
  77. package/authoring/doctypes/component/component.doc.mjs +4 -4
  78. package/authoring/doctypes/component/type.ts +6 -3
  79. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  80. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  81. package/authoring/doctypes/template/parse.d.mts +6 -2
  82. package/authoring/doctypes/template/parse.mjs +3 -1
  83. package/authoring/doctypes/template/type.ts +22 -0
  84. package/authoring/index.d.ts +1 -0
  85. package/authoring/integration/integration.doc.mjs +8 -1
  86. package/authoring/integration/parse.test.mjs +10 -0
  87. package/authoring/integration/schema.d.mts +2 -0
  88. package/authoring/integration/schema.mjs +1 -0
  89. package/authoring/integration/type.ts +4 -0
  90. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  91. package/clients/cli/commands/build-theme.mjs +1 -1
  92. package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
  93. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  94. package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
  95. package/clients/cli/commands/doctor-integration.test.mjs +392 -0
  96. package/clients/cli/commands/doctor.mjs +74 -0
  97. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  98. package/clients/cli/lib/component-format.mjs +5 -1
  99. package/foundation/config/project.mjs +82 -0
  100. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  101. package/foundation/discovery/component-discovery.d.mts +190 -10
  102. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  103. package/foundation/discovery/component-discovery.mjs +864 -56
  104. package/foundation/discovery/component-discovery.test.mjs +96 -0
  105. package/foundation/discovery/component-replacement.mjs +18 -0
  106. package/foundation/discovery/component-replacement.test.mjs +40 -0
  107. package/foundation/discovery/doc-types.d.mts +157 -0
  108. package/foundation/discovery/doc-types.mjs +1224 -0
  109. package/foundation/discovery/doc-types.test.mjs +652 -0
  110. package/foundation/discovery/docs-discovery.d.mts +81 -0
  111. package/foundation/discovery/docs-discovery.mjs +57 -0
  112. package/foundation/discovery/module-exports.d.mts +27 -0
  113. package/foundation/discovery/module-exports.mjs +356 -31
  114. package/foundation/discovery/module-exports.test.mjs +172 -0
  115. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  116. package/foundation/discovery/package-tsconfig.mjs +228 -0
  117. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  118. package/foundation/discovery/project-typescript.d.mts +23 -0
  119. package/foundation/discovery/project-typescript.mjs +61 -0
  120. package/foundation/discovery/prop-drift.d.mts +220 -0
  121. package/foundation/discovery/prop-drift.mjs +1765 -0
  122. package/foundation/discovery/prop-drift.test.mjs +1197 -0
  123. package/foundation/discovery/template-adapter.mjs +74 -5
  124. package/foundation/discovery/type-match.d.mts +53 -0
  125. package/foundation/discovery/type-match.mjs +660 -0
  126. package/foundation/discovery/type-match.test.mjs +169 -0
  127. package/foundation/discovery/type-text.d.mts +68 -0
  128. package/foundation/discovery/type-text.mjs +658 -0
  129. package/foundation/discovery/type-text.test.mjs +196 -0
  130. package/foundation/discovery/unresolved-references.d.mts +62 -0
  131. package/foundation/discovery/unresolved-references.mjs +790 -0
  132. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  133. package/foundation/doc-compiler/doc-loads.test.mjs +9 -1
  134. package/foundation/doc-compiler/inputs.mjs +23 -0
  135. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  136. package/foundation/doc-compiler/links.d.mts +9 -5
  137. package/foundation/doc-compiler/links.mjs +4 -2
  138. package/foundation/integrations/contribution-inventory.mjs +6 -1
  139. package/foundation/response/response-types.doc.mjs +1 -1
  140. package/foundation/xle/registry.mjs +4 -0
  141. package/foundation/xle/registry.test.mjs +28 -0
  142. package/package.json +10 -10
@@ -25,13 +25,13 @@ export const docs = {
25
25
  type: 'code',
26
26
  lang: 'tsx',
27
27
  label: 'Wire the generated module once',
28
- code: "import {Theme} from '@astryxdesign/core';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
28
+ code: "import {Theme} from '@astryxdesign/core/theme';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
29
29
  },
30
30
  {
31
31
  type: 'code',
32
32
  lang: 'tsx',
33
33
  label: 'Switch among added themes',
34
- code: "import {useState} from 'react';\nimport {Theme} from '@astryxdesign/core';\nimport {themes, type ThemeSlug} from './astryx-themes';\n\nconst [slug, setSlug] = useState<ThemeSlug>('neutral');\nconst app = <Theme theme={themes[slug]}><YourApp /></Theme>;",
34
+ code: "import {useState} from 'react';\nimport {Theme} from '@astryxdesign/core/theme';\nimport {themes, type ThemeSlug} from './astryx-themes';\n\nconst [slug, setSlug] = useState<ThemeSlug>('neutral');\nconst app = <Theme theme={themes[slug]}><YourApp /></Theme>;",
35
35
  },
36
36
  {
37
37
  type: 'prose',
@@ -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
+ };
@@ -0,0 +1,73 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Static header content: title, subtitle, a no-op close handler, and a divider
7
+ * @output The DrawerHeader row at the top of a square-cornered, drawer-width panel, visible without opening an overlay
8
+ * @position DrawerHeader's docsite showcase. Drawer has no inline mode
9
+ * like Dialog's isInline, so a plain panel stands in for the drawer; in an
10
+ * app, compose DrawerHeader in a Layout header slot inside a Drawer.
11
+ */
12
+
13
+ import * as stylex from '@stylexjs/stylex';
14
+ import {DrawerHeader} from '@astryxdesign/core/Drawer';
15
+ import {
16
+ Layout,
17
+ LayoutContent,
18
+ overlayPaddingReset,
19
+ } from '@astryxdesign/core/Layout';
20
+ import {Text} from '@astryxdesign/core/Text';
21
+ import {
22
+ borderVars,
23
+ colorVars,
24
+ spacingVars,
25
+ } from '@astryxdesign/core/theme/tokens.stylex';
26
+
27
+ const styles = stylex.create({
28
+ // A card-like panel with square corners, matching the drawer's own corners.
29
+ panel: {
30
+ width: 360,
31
+ maxWidth: '100%',
32
+ boxSizing: 'border-box',
33
+ backgroundColor: colorVars['--color-background-card'],
34
+ borderWidth: borderVars['--border-width'],
35
+ borderStyle: 'solid',
36
+ borderColor: colorVars['--color-border'],
37
+ borderRadius: 0,
38
+ },
39
+ body: {
40
+ padding: spacingVars['--spacing-4'],
41
+ backgroundColor: colorVars['--color-background-muted'],
42
+ borderRadius: 0,
43
+ },
44
+ });
45
+
46
+ export default function DrawerHeaderShowcase() {
47
+ return (
48
+ // Like the Drawer root, the panel is a padding boundary, so the Layout
49
+ // regions inset by their own --spacing-4 default: the drawer's inset.
50
+ <div {...stylex.props(styles.panel, overlayPaddingReset.reset)}>
51
+ <Layout
52
+ height="auto"
53
+ header={
54
+ <DrawerHeader
55
+ title="Host details"
56
+ subtitle="web-prod-04"
57
+ onOpenChange={() => {}}
58
+ hasDivider
59
+ />
60
+ }
61
+ content={
62
+ <LayoutContent>
63
+ <div {...stylex.props(styles.body)}>
64
+ <Text type="body" color="secondary">
65
+ Drawer body content goes here.
66
+ </Text>
67
+ </div>
68
+ </LayoutContent>
69
+ }
70
+ />
71
+ </div>
72
+ );
73
+ }
@@ -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: 'With subtitle and end content',
7
+ displayName: 'With subtitle and end content',
8
+ description:
9
+ 'Add a subtitle under the title and put a status, such as a Badge, in endContent. The close button stays at the end of the row.',
10
+ exampleFor: 'DrawerHeader',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'DrawerHeader',
16
+ 'Badge',
17
+ 'Button',
18
+ 'Layout',
19
+ 'LayoutContent',
20
+ 'Text',
21
+ ],
22
+ };
@@ -0,0 +1,49 @@
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 DrawerHeader with a subtitle, a status badge in its end slot, and a close button
8
+ * @position Copyable DrawerHeader example
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Drawer, DrawerHeader} from '@astryxdesign/core/Drawer';
13
+ import {Badge} from '@astryxdesign/core/Badge';
14
+ import {Button} from '@astryxdesign/core/Button';
15
+ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
16
+ import {Text} from '@astryxdesign/core/Text';
17
+
18
+ export default function DrawerHeaderSubtitleEndContent() {
19
+ const [isOpen, setIsOpen] = useState(false);
20
+
21
+ return (
22
+ <>
23
+ <Button label="Open host details" onClick={() => setIsOpen(true)} />
24
+ <Drawer
25
+ isOpen={isOpen}
26
+ onOpenChange={setIsOpen}
27
+ label="web-prod-04"
28
+ width={360}>
29
+ <Layout
30
+ header={
31
+ <DrawerHeader
32
+ title="web-prod-04"
33
+ subtitle="us-east-1"
34
+ endContent={<Badge label="Healthy" variant="success" />}
35
+ onOpenChange={setIsOpen}
36
+ />
37
+ }
38
+ content={
39
+ <LayoutContent>
40
+ <Text type="body">
41
+ All 6 instances are passing readiness checks.
42
+ </Text>
43
+ </LayoutContent>
44
+ }
45
+ />
46
+ </Drawer>
47
+ </>
48
+ );
49
+ }
@@ -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: 'With close button',
7
+ displayName: 'With close button',
8
+ description:
9
+ 'Pass onOpenChange to render a close button that calls it with false. Drawer renders no close button of its own, so this is the usual visible way to close.',
10
+ exampleFor: 'DrawerHeader',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Drawer',
15
+ 'DrawerHeader',
16
+ 'Button',
17
+ 'Layout',
18
+ 'LayoutContent',
19
+ 'Text',
20
+ ],
21
+ };