@astryxdesign/cli 0.1.4-canary.efa3ea5 → 0.1.4-canary.f01eb10

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 (29) hide show
  1. package/docs/getting-started.doc.mjs +0 -4
  2. package/docs/migration.doc.mjs +0 -134
  3. package/docs/styling.doc.mjs +0 -53
  4. package/package.json +9 -9
  5. package/src/commands/agent-docs.mjs +5 -7
  6. package/src/commands/agent-docs.test.mjs +0 -33
  7. package/src/commands/build-theme.mjs +1 -8
  8. package/src/commands/init.mjs +1 -1
  9. package/src/commands/swizzle.mjs +0 -34
  10. package/src/commands/swizzle.routing.test.mjs +0 -67
  11. package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
  12. package/templates/pages/classic-gallery/page.tsx +1 -1
  13. package/templates/pages/dashboard/page.tsx +1 -1
  14. package/templates/pages/documentation/page.tsx +1 -1
  15. package/templates/pages/mixed-gallery/page.tsx +1 -1
  16. package/templates/pages/payment-form/page.tsx +6 -2
  17. package/templates/pages/product-detail/page.tsx +11 -3
  18. package/templates/pages/product-gallery/page.tsx +1 -1
  19. package/templates/pages/settings/page.tsx +1 -1
  20. package/templates/pages/side-gallery/page.tsx +1 -1
  21. package/templates/pages/table-page/page.tsx +1 -1
  22. package/templates/pages/table-page-chart/page.tsx +1 -1
  23. package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
  24. package/templates/pages/table-page-shoe-store-heatmap/page.tsx +1 -1
  25. package/src/commands/build-theme.color-scheme.test.mjs +0 -153
  26. package/templates/pages/incident-console/page.tsx +0 -580
  27. package/templates/pages/incident-console/template.doc.mjs +0 -12
  28. package/templates/pages/messaging-shell/page.tsx +0 -676
  29. package/templates/pages/messaging-shell/template.doc.mjs +0 -12
@@ -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
- });