@astryxdesign/cli 0.1.4-canary.38ede5f → 0.1.4-canary.39ffd21
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.
- package/CHANGELOG.md +1 -2
- package/docs/getting-started.doc.mjs +0 -4
- package/docs/migration.doc.mjs +0 -134
- package/docs/styling.doc.mjs +0 -53
- package/package.json +10 -15
- package/src/api/component.mjs +1 -2
- package/src/api/doctor.mjs +2 -13
- package/src/api/template.mjs +3 -14
- package/src/codemods/__tests__/runner.test.mjs +0 -38
- package/src/codemods/runner.mjs +0 -2
- package/src/commands/agent-docs.mjs +6 -9
- package/src/commands/agent-docs.test.mjs +0 -33
- package/src/commands/build-theme.mjs +14 -118
- package/src/commands/component-resolution.test.mjs +4 -4
- package/src/commands/doctor.test.mjs +0 -34
- package/src/commands/init.mjs +1 -1
- package/src/commands/swizzle.mjs +0 -34
- package/src/commands/swizzle.routing.test.mjs +0 -67
- package/src/lib/component-discovery.mjs +4 -8
- package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
- package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +48 -27
- package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +54 -31
- package/templates/pages/classic-gallery/page.tsx +1 -1
- package/templates/pages/dashboard/page.tsx +1 -1
- package/templates/pages/documentation/page.tsx +1 -1
- package/templates/pages/mixed-gallery/page.tsx +1 -1
- package/templates/pages/payment-form/page.tsx +6 -2
- package/templates/pages/product-detail/page.tsx +11 -3
- package/templates/pages/product-gallery/page.tsx +1 -1
- package/templates/pages/settings/page.tsx +1 -1
- package/templates/pages/side-gallery/page.tsx +1 -1
- package/templates/pages/table-page/page.tsx +1 -1
- package/templates/pages/table-page-chart/page.tsx +14 -4
- package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +19 -5
- package/src/commands/build-theme.color-scheme.test.mjs +0 -153
- package/src/commands/build-theme.variants.test.mjs +0 -193
- package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +0 -14
- package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +0 -58
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +0 -14
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +0 -24
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +0 -13
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +0 -33
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +0 -39
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +0 -39
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +0 -27
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +0 -38
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +0 -14
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +0 -44
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +0 -15
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +0 -107
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +0 -15
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +0 -47
- package/templates/pages/incident-console/page.tsx +0 -580
- package/templates/pages/incident-console/template.doc.mjs +0 -12
- package/templates/pages/messaging-shell/page.tsx +0 -676
- package/templates/pages/messaging-shell/template.doc.mjs +0 -12
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
5
|
import {useMemo, type CSSProperties} from 'react';
|
|
6
|
-
import {
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{item
|
|
53
|
-
|
|
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
|
}
|
|
@@ -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="
|
|
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 {
|
|
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
|
|
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="
|
|
289
|
+
height="auto"
|
|
282
290
|
contentWidth={1200}
|
|
283
291
|
content={
|
|
284
292
|
<LayoutContent padding={6}>
|
|
@@ -19,7 +19,13 @@ import {Link} from '@astryxdesign/core/Link';
|
|
|
19
19
|
import {Thumbnail} from '@astryxdesign/core/Thumbnail';
|
|
20
20
|
import {Table, proportional, pixel} from '@astryxdesign/core/Table';
|
|
21
21
|
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ChartV2 as Chart,
|
|
24
|
+
ChartGrid,
|
|
25
|
+
ChartAxis,
|
|
26
|
+
area,
|
|
27
|
+
line,
|
|
28
|
+
} from '@astryxdesign/lab';
|
|
23
29
|
import {
|
|
24
30
|
FunnelIcon,
|
|
25
31
|
ArrowDownTrayIcon,
|
|
@@ -475,13 +481,17 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
475
481
|
key: 'amount',
|
|
476
482
|
header: 'Amount',
|
|
477
483
|
width: pixel(90),
|
|
478
|
-
renderCell: (item: OrderRow) =>
|
|
484
|
+
renderCell: (item: OrderRow) => (
|
|
485
|
+
<Text type="body">${item.amount}</Text>
|
|
486
|
+
),
|
|
479
487
|
},
|
|
480
488
|
{
|
|
481
489
|
key: 'customer',
|
|
482
490
|
header: 'Customer',
|
|
483
491
|
width: proportional(2),
|
|
484
|
-
renderCell: (item: OrderRow) =>
|
|
492
|
+
renderCell: (item: OrderRow) => (
|
|
493
|
+
<Text type="body">{item.customer}</Text>
|
|
494
|
+
),
|
|
485
495
|
},
|
|
486
496
|
{
|
|
487
497
|
key: 'email',
|
|
@@ -513,7 +523,7 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
513
523
|
export default function TablePageChartTemplate() {
|
|
514
524
|
return (
|
|
515
525
|
<Layout
|
|
516
|
-
height="
|
|
526
|
+
height="auto"
|
|
517
527
|
header={
|
|
518
528
|
<LayoutHeader hasDivider>
|
|
519
529
|
<HStack gap={2} vAlign="center">
|
|
@@ -19,7 +19,13 @@ import {Link} from '@astryxdesign/core/Link';
|
|
|
19
19
|
import {Thumbnail} from '@astryxdesign/core/Thumbnail';
|
|
20
20
|
import {Table, proportional, pixel} from '@astryxdesign/core/Table';
|
|
21
21
|
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ChartV2 as Chart,
|
|
24
|
+
ChartGrid,
|
|
25
|
+
ChartAxis,
|
|
26
|
+
area,
|
|
27
|
+
line,
|
|
28
|
+
} from '@astryxdesign/lab';
|
|
23
29
|
import {
|
|
24
30
|
FunnelIcon,
|
|
25
31
|
ArrowDownTrayIcon,
|
|
@@ -29,7 +35,11 @@ import {
|
|
|
29
35
|
// ============= DATA =============
|
|
30
36
|
|
|
31
37
|
type ProductCategory =
|
|
32
|
-
|
|
38
|
+
| 'Running'
|
|
39
|
+
| 'Lifestyle'
|
|
40
|
+
| 'Basketball'
|
|
41
|
+
| 'Training'
|
|
42
|
+
| 'Skateboarding';
|
|
33
43
|
|
|
34
44
|
function shoeSvg(bg: string, accent: string) {
|
|
35
45
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" rx="12" fill="${bg}"/><g transform="translate(22.5, 22.5) scale(2.29)" fill="none" stroke="${accent}" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m15 10.42 4.8-5.07"/><path d="M19 18h3"/><path d="M9.5 22 21.414 9.415A2 2 0 0 0 21.2 6.4l-5.61-4.208A1 1 0 0 0 14 3v2a2 2 0 0 1-1.394 1.906L8.677 8.053A1 1 0 0 0 8 9c-.155 6.393-2.082 9-4 9a2 2 0 0 0 0 4h14"/></g></svg>`;
|
|
@@ -829,13 +839,17 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
829
839
|
key: 'amount',
|
|
830
840
|
header: 'Amount',
|
|
831
841
|
width: pixel(90),
|
|
832
|
-
renderCell: (item: OrderRow) =>
|
|
842
|
+
renderCell: (item: OrderRow) => (
|
|
843
|
+
<Text type="body">${item.amount}</Text>
|
|
844
|
+
),
|
|
833
845
|
},
|
|
834
846
|
{
|
|
835
847
|
key: 'customer',
|
|
836
848
|
header: 'Customer',
|
|
837
849
|
width: proportional(2),
|
|
838
|
-
renderCell: (item: OrderRow) =>
|
|
850
|
+
renderCell: (item: OrderRow) => (
|
|
851
|
+
<Text type="body">{item.customer}</Text>
|
|
852
|
+
),
|
|
839
853
|
},
|
|
840
854
|
{
|
|
841
855
|
key: 'email',
|
|
@@ -867,7 +881,7 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
867
881
|
export default function TablePageShoeStoreHeatmapTemplate() {
|
|
868
882
|
return (
|
|
869
883
|
<Layout
|
|
870
|
-
height="
|
|
884
|
+
height="auto"
|
|
871
885
|
header={
|
|
872
886
|
<LayoutHeader hasDivider>
|
|
873
887
|
<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
|
-
});
|