@astryxdesign/cli 0.1.4-canary.e009fdd → 0.1.4-canary.e18ed0f

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 (46) hide show
  1. package/CHANGELOG.md +1 -2
  2. package/docs/getting-started.doc.mjs +0 -4
  3. package/docs/migration.doc.mjs +0 -134
  4. package/docs/styling.doc.mjs +0 -53
  5. package/package.json +10 -10
  6. package/src/commands/agent-docs.mjs +5 -7
  7. package/src/commands/agent-docs.test.mjs +0 -33
  8. package/src/commands/build-theme.mjs +1 -8
  9. package/src/commands/build-theme.variants.test.mjs +18 -7
  10. package/src/commands/init.mjs +1 -1
  11. package/src/commands/swizzle.mjs +0 -34
  12. package/src/commands/swizzle.routing.test.mjs +0 -67
  13. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +1 -1
  14. package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
  15. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +48 -27
  16. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +54 -31
  17. package/templates/pages/classic-gallery/page.tsx +1 -1
  18. package/templates/pages/dashboard/page.tsx +1 -1
  19. package/templates/pages/documentation/page.tsx +1 -1
  20. package/templates/pages/mixed-gallery/page.tsx +1 -1
  21. package/templates/pages/payment-form/page.tsx +6 -2
  22. package/templates/pages/product-detail/page.tsx +11 -3
  23. package/templates/pages/product-gallery/page.tsx +1 -1
  24. package/templates/pages/settings/page.tsx +1 -1
  25. package/templates/pages/side-gallery/page.tsx +1 -1
  26. package/templates/pages/table-page/page.tsx +1 -1
  27. package/templates/pages/table-page-chart/page.tsx +1 -1
  28. package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
  29. package/templates/pages/table-page-shoe-store-heatmap/page.tsx +1 -1
  30. package/src/commands/build-theme.color-scheme.test.mjs +0 -153
  31. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +0 -15
  32. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +0 -39
  33. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +0 -15
  34. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +0 -39
  35. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +0 -15
  36. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +0 -27
  37. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +0 -15
  38. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +0 -38
  39. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +0 -14
  40. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +0 -44
  41. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +0 -15
  42. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +0 -107
  43. package/templates/pages/incident-console/page.tsx +0 -580
  44. package/templates/pages/incident-console/template.doc.mjs +0 -12
  45. package/templates/pages/messaging-shell/page.tsx +0 -676
  46. package/templates/pages/messaging-shell/template.doc.mjs +0 -12
@@ -2,36 +2,34 @@
2
2
 
3
3
  'use client';
4
4
 
5
- import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
5
+ import {Collapsible} from '@astryxdesign/core/Collapsible';
6
6
  import {Divider} from '@astryxdesign/core/Divider';
7
7
  import {Text} from '@astryxdesign/core/Text';
8
8
  import {VStack} from '@astryxdesign/core/Layout';
9
9
 
10
10
  export default function CollapsibleWithoutCard() {
11
11
  return (
12
- <CollapsibleGroup type="single" defaultValue="deployment">
13
- <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
14
- <Collapsible trigger="Deployment Details" value="deployment">
15
- <Text type="body">
16
- Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
17
- duration was 2m 14s with zero warnings.
18
- </Text>
19
- </Collapsible>
20
- <Divider />
21
- <Collapsible trigger="Environment Variables" value="environment">
22
- <Text type="body">
23
- 12 variables configured. Last updated March 30, 2026. All secrets
24
- are encrypted at rest with AES-256.
25
- </Text>
26
- </Collapsible>
27
- <Divider />
28
- <Collapsible trigger="Build Logs" value="logs">
29
- <Text type="body">
30
- Build completed successfully. 847 modules compiled, 0 errors, 0
31
- warnings. Bundle size: 142 KB gzipped.
32
- </Text>
33
- </Collapsible>
34
- </VStack>
35
- </CollapsibleGroup>
12
+ <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
13
+ <Collapsible trigger="Deployment Details">
14
+ <Text type="body">
15
+ Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
16
+ duration was 2m 14s with zero warnings.
17
+ </Text>
18
+ </Collapsible>
19
+ <Divider />
20
+ <Collapsible trigger="Environment Variables" defaultIsOpen={false}>
21
+ <Text type="body">
22
+ 12 variables configured. Last updated March 30, 2026. All secrets are
23
+ encrypted at rest with AES-256.
24
+ </Text>
25
+ </Collapsible>
26
+ <Divider />
27
+ <Collapsible trigger="Build Logs" defaultIsOpen={false}>
28
+ <Text type="body">
29
+ Build completed successfully. 847 modules compiled, 0 errors, 0
30
+ warnings. Bundle size: 142 KB gzipped.
31
+ </Text>
32
+ </Collapsible>
33
+ </VStack>
36
34
  );
37
35
  }
@@ -3,45 +3,66 @@
3
3
  'use client';
4
4
 
5
5
  import {useMemo} from 'react';
6
- import {CommandPalette} from '@astryxdesign/core/CommandPalette';
6
+ import {
7
+ CommandPalette,
8
+ CommandPaletteList,
9
+ CommandPaletteGroup,
10
+ CommandPaletteItem,
11
+ } from '@astryxdesign/core/CommandPalette';
7
12
  import {createStaticSource} from '@astryxdesign/core/Typeahead';
13
+ import {Stack} from '@astryxdesign/core/Layout';
14
+ import {Text} from '@astryxdesign/core/Text';
8
15
 
9
16
  export default function CommandPaletteGroupShowcase() {
10
17
  const source = useMemo(
11
18
  () =>
12
19
  createStaticSource([
13
- {
14
- id: 'index',
15
- label: 'index.tsx',
16
- auxiliaryData: {group: 'Recent Files'},
17
- },
20
+ {id: 'index', label: 'index.tsx', auxiliaryData: {group: 'Recent Files'}},
18
21
  {id: 'app', label: 'App.tsx', auxiliaryData: {group: 'Recent Files'}},
19
- {
20
- id: 'settings',
21
- label: 'Open Settings',
22
- auxiliaryData: {group: 'Commands'},
23
- },
24
- {
25
- id: 'terminal',
26
- label: 'Toggle Terminal',
27
- auxiliaryData: {group: 'Commands'},
28
- },
29
- {
30
- id: 'theme',
31
- label: 'Color Theme',
32
- auxiliaryData: {group: 'Preferences'},
33
- },
22
+ {id: 'settings', label: 'Open Settings', auxiliaryData: {group: 'Commands'}},
23
+ {id: 'terminal', label: 'Toggle Terminal', auxiliaryData: {group: 'Commands'}},
24
+ {id: 'theme', label: 'Color Theme', auxiliaryData: {group: 'Preferences'}},
34
25
  {id: 'font', label: 'Font Size', auxiliaryData: {group: 'Preferences'}},
35
26
  ]),
36
27
  [],
37
28
  );
38
29
 
39
30
  return (
40
- <CommandPalette
41
- isOpen
42
- isInline
43
- onOpenChange={() => {}}
44
- searchSource={source}
45
- />
31
+ <Stack direction="vertical" gap={4}>
32
+ <Stack direction="vertical" gap={1}>
33
+ <Text type="supporting" color="secondary">
34
+ Data-driven grouping (auxiliaryData.group)
35
+ </Text>
36
+ <CommandPalette
37
+ isOpen
38
+ isInline
39
+ onOpenChange={() => {}}
40
+ searchSource={source}
41
+ />
42
+ </Stack>
43
+ <Stack direction="vertical" gap={1}>
44
+ <Text type="supporting" color="secondary">
45
+ Composed form (CommandPaletteGroup + CommandPaletteItem)
46
+ </Text>
47
+ <CommandPaletteList>
48
+ <CommandPaletteGroup heading="Navigation">
49
+ <CommandPaletteItem value="home" onSelect={() => {}}>
50
+ Home
51
+ </CommandPaletteItem>
52
+ <CommandPaletteItem value="dashboard" onSelect={() => {}}>
53
+ Dashboard
54
+ </CommandPaletteItem>
55
+ </CommandPaletteGroup>
56
+ <CommandPaletteGroup heading="Actions">
57
+ <CommandPaletteItem value="new-file" onSelect={() => {}}>
58
+ New File
59
+ </CommandPaletteItem>
60
+ <CommandPaletteItem value="save" onSelect={() => {}}>
61
+ Save All
62
+ </CommandPaletteItem>
63
+ </CommandPaletteGroup>
64
+ </CommandPaletteList>
65
+ </Stack>
66
+ </Stack>
46
67
  );
47
68
  }
@@ -3,10 +3,16 @@
3
3
  'use client';
4
4
 
5
5
  import {useMemo, type CSSProperties} from 'react';
6
- import {CommandPalette} from '@astryxdesign/core/CommandPalette';
6
+ import {
7
+ CommandPalette,
8
+ CommandPaletteList,
9
+ CommandPaletteItem,
10
+ } from '@astryxdesign/core/CommandPalette';
7
11
  import {Text} from '@astryxdesign/core/Text';
8
12
  import {Kbd} from '@astryxdesign/core/Kbd';
13
+ import {Icon} from '@astryxdesign/core/Icon';
9
14
  import {createStaticSource} from '@astryxdesign/core/Typeahead';
15
+ import {Stack} from '@astryxdesign/core/Layout';
10
16
  import type {SearchableItem} from '@astryxdesign/core/Typeahead';
11
17
 
12
18
  const itemLabel: CSSProperties = {
@@ -17,21 +23,9 @@ type CommandItem = SearchableItem<{shortcut?: string}>;
17
23
 
18
24
  const commands: CommandItem[] = [
19
25
  {id: 'save', label: 'Save File', auxiliaryData: {shortcut: 'mod+s'}},
20
- {
21
- id: 'find',
22
- label: 'Find in Files',
23
- auxiliaryData: {shortcut: 'mod+shift+f'},
24
- },
25
- {
26
- id: 'palette',
27
- label: 'Command Palette',
28
- auxiliaryData: {shortcut: 'mod+shift+p'},
29
- },
30
- {
31
- id: 'terminal',
32
- label: 'Toggle Terminal',
33
- auxiliaryData: {shortcut: 'ctrl+`'},
34
- },
26
+ {id: 'find', label: 'Find in Files', auxiliaryData: {shortcut: 'mod+shift+f'}},
27
+ {id: 'palette', label: 'Command Palette', auxiliaryData: {shortcut: 'mod+shift+p'}},
28
+ {id: 'terminal', label: 'Toggle Terminal', auxiliaryData: {shortcut: 'ctrl+`'}},
35
29
  {id: 'sidebar', label: 'Toggle Sidebar', auxiliaryData: {shortcut: 'mod+b'}},
36
30
  ];
37
31
 
@@ -39,21 +33,50 @@ export default function CommandPaletteItemShowcase() {
39
33
  const source = useMemo(() => createStaticSource(commands), []);
40
34
 
41
35
  return (
42
- <CommandPalette
43
- isOpen
44
- isInline
45
- onOpenChange={() => {}}
46
- searchSource={source}
47
- renderItem={(item: CommandItem) => (
48
- <>
49
- <Text type="body" style={itemLabel}>
50
- {item.label}
51
- </Text>
52
- {item.auxiliaryData?.shortcut && (
53
- <Kbd keys={item.auxiliaryData.shortcut} />
36
+ <Stack direction="vertical" gap={4}>
37
+ <Stack direction="vertical" gap={1}>
38
+ <Text type="supporting" color="secondary">
39
+ Custom renderItem with keyboard shortcuts
40
+ </Text>
41
+ <CommandPalette
42
+ isOpen
43
+ isInline
44
+ onOpenChange={() => {}}
45
+ searchSource={source}
46
+ renderItem={(item: CommandItem) => (
47
+ <>
48
+ <Text type="body" style={itemLabel}>
49
+ {item.label}
50
+ </Text>
51
+ {item.auxiliaryData?.shortcut && (
52
+ <Kbd keys={item.auxiliaryData.shortcut} />
53
+ )}
54
+ </>
54
55
  )}
55
- </>
56
- )}
57
- />
56
+ />
57
+ </Stack>
58
+ <Stack direction="vertical" gap={1}>
59
+ <Text type="supporting" color="secondary">
60
+ Composed items with icons and states
61
+ </Text>
62
+ <CommandPaletteList>
63
+ <CommandPaletteItem value="home" onSelect={() => {}}>
64
+ <Icon icon="externalLink" size="sm" />
65
+ <Text type="body" style={itemLabel}>Home</Text>
66
+ </CommandPaletteItem>
67
+ <CommandPaletteItem value="search" isHighlighted onSelect={() => {}}>
68
+ <Icon icon="search" size="sm" />
69
+ <Text type="body" style={itemLabel}>Search (highlighted)</Text>
70
+ </CommandPaletteItem>
71
+ <CommandPaletteItem value="selected" isSelected onSelect={() => {}}>
72
+ <Icon icon="check" size="sm" />
73
+ <Text type="body" style={itemLabel}>Selected item</Text>
74
+ </CommandPaletteItem>
75
+ <CommandPaletteItem value="disabled" isDisabled>
76
+ <Text type="body" style={itemLabel}>Disabled item</Text>
77
+ </CommandPaletteItem>
78
+ </CommandPaletteList>
79
+ </Stack>
80
+ </Stack>
58
81
  );
59
82
  }
@@ -110,7 +110,7 @@ export default function ClassicGalleryTemplate() {
110
110
 
111
111
  return (
112
112
  <Layout
113
- height="fill"
113
+ height="auto"
114
114
  content={
115
115
  <LayoutContent padding={0}>
116
116
  <Center axis="horizontal">
@@ -729,7 +729,7 @@ function TableCard<T extends {id: string}>({
729
729
  export default function DashboardTemplate() {
730
730
  return (
731
731
  <Layout
732
- height="fill"
732
+ height="auto"
733
733
  content={
734
734
  <LayoutContent padding={6}>
735
735
  <VStack gap={6}>
@@ -209,7 +209,7 @@ const COMPONENT_CATEGORIES = [
209
209
  export default function DocumentationOverviewPage() {
210
210
  return (
211
211
  <Layout
212
- height="fill"
212
+ height="auto"
213
213
  contentWidth={1200}
214
214
  content={
215
215
  <LayoutContent padding={8}>
@@ -112,7 +112,7 @@ function GalleryCard({
112
112
  export default function MixedGalleryTemplate() {
113
113
  return (
114
114
  <Layout
115
- height="fill"
115
+ height="auto"
116
116
  contentWidth={1400}
117
117
  content={
118
118
  <LayoutContent padding={6}>
@@ -153,6 +153,10 @@ const fmt = (n: number) => `$${n.toFixed(2)}`;
153
153
  // :root by `@astryxdesign/core/astryx.css`). No StyleX compiler required.
154
154
 
155
155
  const fullWidth: CSSProperties = {width: '100%'};
156
+ // LayoutContent clips overflow by default, which traps position:sticky
157
+ // children (the sticky order summary). With height="auto" the page scrolls
158
+ // at the window, so let overflow be visible here so sticky can pin.
159
+ const visibleOverflow: CSSProperties = {overflow: 'visible'};
156
160
  // Form column flex-basis so the two checkout columns share width evenly.
157
161
  const formColBasis: CSSProperties = {flexBasis: 0};
158
162
  // Space the Order Summary content below its collapsible trigger title.
@@ -262,9 +266,9 @@ export default function PaymentFormPage() {
262
266
 
263
267
  return (
264
268
  <Layout
265
- height="fill"
269
+ height="auto"
266
270
  content={
267
- <LayoutContent padding={0}>
271
+ <LayoutContent padding={0} style={visibleOverflow}>
268
272
  <Center axis="horizontal">
269
273
  <Section
270
274
  variant="transparent"
@@ -3,7 +3,12 @@
3
3
  'use client';
4
4
 
5
5
  import {useState} from 'react';
6
- import {VStack, HStack, Layout, LayoutContent} from '@astryxdesign/core/Layout';
6
+ import {
7
+ VStack,
8
+ HStack,
9
+ Layout,
10
+ LayoutContent,
11
+ } from '@astryxdesign/core/Layout';
7
12
  import {Center} from '@astryxdesign/core/Center';
8
13
  import {Grid} from '@astryxdesign/core/Grid';
9
14
  import {Text, Heading} from '@astryxdesign/core/Text';
@@ -198,7 +203,10 @@ function ProductInfo() {
198
203
  <VStack gap={2}>
199
204
  <Text type="label">Finish</Text>
200
205
  <VStack hAlign="start">
201
- <SegmentedControl value={finish} onChange={setFinish} label="Finish">
206
+ <SegmentedControl
207
+ value={finish}
208
+ onChange={setFinish}
209
+ label="Finish">
202
210
  {FINISHES.map(f => (
203
211
  <SegmentedControlItem
204
212
  key={f.value}
@@ -278,7 +286,7 @@ export default function ProductDetailTemplate() {
278
286
 
279
287
  return (
280
288
  <Layout
281
- height="fill"
289
+ height="auto"
282
290
  contentWidth={1200}
283
291
  content={
284
292
  <LayoutContent padding={6}>
@@ -119,7 +119,7 @@ function ProductCard({product}: {product: Product}) {
119
119
  export default function ProductGalleryTemplate() {
120
120
  return (
121
121
  <Layout
122
- height="fill"
122
+ height="auto"
123
123
  contentWidth={1200}
124
124
  content={
125
125
  <LayoutContent padding={6}>
@@ -70,7 +70,7 @@ export default function SettingsTemplate() {
70
70
 
71
71
  return (
72
72
  <Layout
73
- height="fill"
73
+ height="auto"
74
74
  contentWidth={1440}
75
75
  header={
76
76
  <LayoutHeader hasDivider>
@@ -101,7 +101,7 @@ function ImageGrid() {
101
101
  export default function SideGalleryTemplate() {
102
102
  return (
103
103
  <Layout
104
- height="fill"
104
+ height="auto"
105
105
  contentWidth={1400}
106
106
  content={
107
107
  <LayoutContent padding={6}>
@@ -389,7 +389,7 @@ export default function TablePageTemplate() {
389
389
 
390
390
  return (
391
391
  <Layout
392
- height="fill"
392
+ height="auto"
393
393
  header={
394
394
  <LayoutHeader hasDivider>
395
395
  <HStack gap={2} vAlign="center">
@@ -513,7 +513,7 @@ const columns: TableColumn<OrderRow>[] = [
513
513
  export default function TablePageChartTemplate() {
514
514
  return (
515
515
  <Layout
516
- height="fill"
516
+ height="auto"
517
517
  header={
518
518
  <LayoutHeader hasDivider>
519
519
  <HStack gap={2} vAlign="center">
@@ -430,7 +430,7 @@ function OutageHeatmap() {
430
430
  export default function TablePageHeatmapStatusTemplate() {
431
431
  return (
432
432
  <Layout
433
- height="fill"
433
+ height="auto"
434
434
  header={
435
435
  <LayoutHeader hasDivider>
436
436
  <HStack gap={2} vAlign="center">
@@ -867,7 +867,7 @@ const columns: TableColumn<OrderRow>[] = [
867
867
  export default function TablePageShoeStoreHeatmapTemplate() {
868
868
  return (
869
869
  <Layout
870
- height="fill"
870
+ height="auto"
871
871
  header={
872
872
  <LayoutHeader hasDivider>
873
873
  <HStack gap={2} vAlign="center">
@@ -1,153 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Regression test for the `color-scheme` declaration `astryx theme build`
5
- * emits alongside `light-dark()` token output (see #3658).
6
- *
7
- * `astryx theme build` injects a `color-scheme` declaration into
8
- * `@layer astryx-theme` whenever the generated CSS contains `light-dark()`,
9
- * so LightningCSS/browsers can resolve it. That declaration must mirror
10
- * reset.css's own `html[data-theme]` -> `color-scheme` mapping (a bare
11
- * `:root { color-scheme: light dark; }` alone permanently pins the page to
12
- * "light dark", defeating `<Theme mode="light|dark">` forcing regardless of
13
- * `@layer astryx-theme` being declared after `@layer reset` in layer order):
14
- *
15
- * :root { color-scheme: light dark; }
16
- * html[data-theme="light"] { color-scheme: light; }
17
- * html[data-theme="dark"] { color-scheme: dark; }
18
- *
19
- * Themes that never use `light-dark()` have no `color-scheme` ambiguity to
20
- * resolve, so none of the three rules should be emitted for them.
21
- *
22
- * Building `astryx theme build` requires a compiled @astryxdesign/core (there is no in-CLI
23
- * fallback generator), so this suite builds core once in beforeAll via the
24
- * shared ensureCoreBuilt() helper — which serializes concurrent Vitest workers
25
- * behind a lock — to stay self-sufficient regardless of CI job ordering.
26
- */
27
-
28
- import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
29
- import {execFileSync} from 'node:child_process';
30
- import * as fs from 'node:fs';
31
- import * as path from 'node:path';
32
- import * as os from 'node:os';
33
- import {fileURLToPath} from 'node:url';
34
- import {ensureCoreBuilt} from './ensure-core-built.mjs';
35
-
36
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
37
- const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
38
-
39
- const COLOR_SCHEME_ROOT_DECL = ':root { color-scheme: light dark; }';
40
- const COLOR_SCHEME_LIGHT_DECL = 'html[data-theme="light"] { color-scheme: light; }';
41
- const COLOR_SCHEME_DARK_DECL = 'html[data-theme="dark"] { color-scheme: dark; }';
42
-
43
- function runCli(args, cwd) {
44
- try {
45
- const out = execFileSync('node', [CLI_BIN, ...args], {
46
- cwd,
47
- encoding: 'utf-8',
48
- stdio: ['ignore', 'pipe', 'pipe'],
49
- env: {...process.env, FORCE_COLOR: '0'},
50
- });
51
- return {code: 0, stdout: out, stderr: ''};
52
- } catch (e) {
53
- return {
54
- code: e.status ?? 1,
55
- stdout: e.stdout?.toString() ?? '',
56
- stderr: e.stderr?.toString() ?? '',
57
- };
58
- }
59
- }
60
-
61
- function writeTheme(dir, name, tokens) {
62
- fs.mkdirSync(dir, {recursive: true});
63
- // The CLI writes <basename>.css next to the source file, so use the
64
- // theme name as the filename for unambiguous fixtures.
65
- const file = path.join(dir, `${name}.mjs`);
66
- fs.writeFileSync(
67
- file,
68
- `export default { name: ${JSON.stringify(name)}, tokens: ${JSON.stringify(tokens)} };\n`,
69
- );
70
- return file;
71
- }
72
-
73
- // `astryx theme build` imports the compiled @astryxdesign/core/theme entry. Build core
74
- // once if it isn't already present so the suite works in any CI job.
75
- beforeAll(() => {
76
- ensureCoreBuilt();
77
- }, 200_000);
78
-
79
- let tmpDir;
80
- beforeEach(() => {
81
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-color-scheme-'));
82
- });
83
- afterEach(() => {
84
- fs.rmSync(tmpDir, {recursive: true, force: true});
85
- });
86
-
87
- describe('theme build color-scheme output', () => {
88
- it('emits the mode-aware color-scheme rules in @layer astryx-theme for a light-dark() theme', () => {
89
- const project = path.join(tmpDir, 'project');
90
- const themesDir = path.join(project, 'themes');
91
- // A raw light-dark() token value is what triggers the color-scheme
92
- // injection in build-theme.mjs (it checks the generated CSS for the
93
- // literal substring). `defineTheme.test.ts` already covers the separate
94
- // [light, dark] tuple -> light-dark() conversion; this fixture writes
95
- // the string directly so this test stays focused on the CLI's own
96
- // color-scheme decision, not on that conversion.
97
- const themeFile = writeTheme(themesDir, 'with-light-dark', {
98
- '--color-accent': 'light-dark(#0077B6, #48CAE4)',
99
- });
100
-
101
- const result = runCli(
102
- ['theme', 'build', path.relative(project, themeFile)],
103
- project,
104
- );
105
-
106
- expect(result.code).toBe(0);
107
-
108
- const cssPath = path.join(themesDir, 'with-light-dark.css');
109
- expect(fs.existsSync(cssPath)).toBe(true);
110
- const css = fs.readFileSync(cssPath, 'utf-8');
111
-
112
- expect(css).toContain('light-dark(#0077B6, #48CAE4)');
113
-
114
- // All 3 rules must be present...
115
- expect(css).toContain(COLOR_SCHEME_ROOT_DECL);
116
- expect(css).toContain(COLOR_SCHEME_LIGHT_DECL);
117
- expect(css).toContain(COLOR_SCHEME_DARK_DECL);
118
-
119
- // ...and specifically inside @layer astryx-theme, not @layer reset (the
120
- // declaration must sit alongside the light-dark() token/component output
121
- // it resolves, not the zero-specificity prose defaults).
122
- const themeLayerStart = css.indexOf('@layer astryx-theme');
123
- expect(themeLayerStart).toBeGreaterThanOrEqual(0);
124
- const themeLayerBody = css.slice(themeLayerStart);
125
- expect(themeLayerBody).toContain(COLOR_SCHEME_ROOT_DECL);
126
- expect(themeLayerBody).toContain(COLOR_SCHEME_LIGHT_DECL);
127
- expect(themeLayerBody).toContain(COLOR_SCHEME_DARK_DECL);
128
- });
129
-
130
- it('omits all color-scheme rules for a theme with no light-dark() tokens', () => {
131
- const project = path.join(tmpDir, 'project');
132
- const themesDir = path.join(project, 'themes');
133
- const themeFile = writeTheme(themesDir, 'no-light-dark', {
134
- '--color-accent': '#0077B6',
135
- });
136
-
137
- const result = runCli(
138
- ['theme', 'build', path.relative(project, themeFile)],
139
- project,
140
- );
141
-
142
- expect(result.code).toBe(0);
143
-
144
- const cssPath = path.join(themesDir, 'no-light-dark.css');
145
- expect(fs.existsSync(cssPath)).toBe(true);
146
- const css = fs.readFileSync(cssPath, 'utf-8');
147
-
148
- expect(css).not.toContain('light-dark(');
149
- expect(css).not.toContain(COLOR_SCHEME_ROOT_DECL);
150
- expect(css).not.toContain(COLOR_SCHEME_LIGHT_DECL);
151
- expect(css).not.toContain(COLOR_SCHEME_DARK_DECL);
152
- });
153
- });
@@ -1,15 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
4
- export const doc = {
5
- type: 'block',
6
- exampleFor: 'CommandPaletteInput',
7
- name: 'CommandPaletteInput — With End Content',
8
- displayName: 'CommandPaletteInput — With End Content',
9
- description:
10
- 'Custom placeholder and a keyboard shortcut badge in the trailing slot via endContent.',
11
- isReady: true,
12
- isShowcase: false,
13
- aspectRatio: 4 / 3,
14
- componentsUsed: ['CommandPalette', 'CommandPaletteInput', 'Kbd'],
15
- };
@@ -1,39 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- 'use client';
4
-
5
- import {useMemo} from 'react';
6
- import {
7
- CommandPalette,
8
- CommandPaletteInput,
9
- } from '@astryxdesign/core/CommandPalette';
10
- import {Kbd} from '@astryxdesign/core/Kbd';
11
- import {createStaticSource} from '@astryxdesign/core/Typeahead';
12
-
13
- export default function CommandPaletteInputBasic() {
14
- const source = useMemo(
15
- () =>
16
- createStaticSource([
17
- {id: 'home', label: 'Home'},
18
- {id: 'settings', label: 'Settings'},
19
- {id: 'profile', label: 'Profile'},
20
- {id: 'help', label: 'Help'},
21
- ]),
22
- [],
23
- );
24
-
25
- return (
26
- <CommandPalette
27
- isOpen
28
- isInline
29
- onOpenChange={() => {}}
30
- searchSource={source}
31
- input={
32
- <CommandPaletteInput
33
- placeholder="Search commands, files, or actions..."
34
- endContent={<Kbd keys="mod+k" />}
35
- />
36
- }
37
- />
38
- );
39
- }
@@ -1,15 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
4
- export const doc = {
5
- type: 'block',
6
- exampleFor: 'CommandPaletteInput',
7
- name: 'CommandPaletteInput',
8
- displayName: 'Command Palette Input',
9
- description:
10
- 'Command palette search input with a custom placeholder and a keyboard shortcut hint in the endContent slot.',
11
- isReady: true,
12
- isShowcase: true,
13
- aspectRatio: 4 / 3,
14
- componentsUsed: ['CommandPalette', 'CommandPaletteInput', 'Kbd'],
15
- };