@astryxdesign/cli 0.1.4-canary.e67829d → 0.1.4-canary.e830adc
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/docs/working-with-ai.doc.mjs +1 -1
- package/package.json +8 -13
- package/src/api/doctor.mjs +2 -13
- package/src/codemods/__tests__/registry.test.mjs +0 -1
- package/src/codemods/__tests__/runner.test.mjs +0 -38
- package/src/codemods/registry.mjs +0 -1
- package/src/codemods/runner.mjs +0 -2
- package/src/commands/agent-docs.mjs +5 -7
- package/src/commands/agent-docs.test.mjs +0 -33
- package/src/commands/build-theme.mjs +1 -2
- package/src/commands/build-theme.variants.test.mjs +18 -7
- 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/templates/blocks/components/AspectRatio/AspectRatioCircleImage.tsx +6 -1
- package/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +7 -2
- package/templates/blocks/components/AspectRatio/AspectRatioShowcase.tsx +5 -2
- package/templates/blocks/components/AspectRatio/AspectRatioSquareImage.tsx +6 -1
- package/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +6 -1
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +1 -1
- 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/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +16 -18
- 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/kanban-board/page.tsx +13 -37
- 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/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
- package/src/codemods/transforms/v0.1.5/index.mjs +0 -19
- package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +0 -140
- package/src/commands/build-theme.color-scheme.test.mjs +0 -153
- 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/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
package/src/commands/swizzle.mjs
CHANGED
|
@@ -26,7 +26,6 @@ import {jsonOut, humanLog} from '../lib/json.mjs';
|
|
|
26
26
|
import {cliError} from '../lib/cli-error.mjs';
|
|
27
27
|
import {ERROR_CODES} from '../lib/error-codes.mjs';
|
|
28
28
|
import {checkGhCli} from '../utils/github.mjs';
|
|
29
|
-
import {getRunPrefix} from '../utils/package-manager.mjs';
|
|
30
29
|
import {Project} from '../lib/project.mjs';
|
|
31
30
|
import {
|
|
32
31
|
CORE_PACKAGE,
|
|
@@ -340,10 +339,6 @@ export function registerSwizzle(program) {
|
|
|
340
339
|
// Copy all non-test, non-doc, non-README files
|
|
341
340
|
const files = fs.readdirSync(componentDir);
|
|
342
341
|
let copied = 0;
|
|
343
|
-
// Track whether any copied source uses StyleX. Swizzled StyleX source
|
|
344
|
-
// needs a build-time StyleX compiler in the consumer's app or it renders
|
|
345
|
-
// unstyled with no error — so we surface a setup note after copying.
|
|
346
|
-
let usesStyleX = false;
|
|
347
342
|
|
|
348
343
|
for (const file of files) {
|
|
349
344
|
// Skip test files, doc files, and README
|
|
@@ -360,13 +355,6 @@ export function registerSwizzle(program) {
|
|
|
360
355
|
content = rewriteImports(content, owner.ownerPackage);
|
|
361
356
|
}
|
|
362
357
|
|
|
363
|
-
if (
|
|
364
|
-
(file.endsWith('.ts') || file.endsWith('.tsx')) &&
|
|
365
|
-
content.includes('@stylexjs/stylex')
|
|
366
|
-
) {
|
|
367
|
-
usesStyleX = true;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
358
|
fs.writeFileSync(path.join(outputDir, file), content);
|
|
371
359
|
copied++;
|
|
372
360
|
}
|
|
@@ -388,7 +376,6 @@ export function registerSwizzle(program) {
|
|
|
388
376
|
outputDir: relOutput,
|
|
389
377
|
filesCopied: copied,
|
|
390
378
|
files: copiedFiles.map(f => f),
|
|
391
|
-
usesStyleX,
|
|
392
379
|
};
|
|
393
380
|
if (feedback) payload.feedback = feedback;
|
|
394
381
|
return jsonOut('swizzle.copy', payload);
|
|
@@ -400,27 +387,6 @@ export function registerSwizzle(program) {
|
|
|
400
387
|
);
|
|
401
388
|
humanLog('You can now customize the component source freely.\n');
|
|
402
389
|
|
|
403
|
-
// StyleX build requirement. Swizzled components ship raw StyleX source,
|
|
404
|
-
// which needs a build-time StyleX compiler in the consumer's app to
|
|
405
|
-
// produce atomic CSS. Without it the component compiles but renders
|
|
406
|
-
// unstyled, with no error — a confusing silent failure, so call it out.
|
|
407
|
-
if (usesStyleX) {
|
|
408
|
-
humanLog(
|
|
409
|
-
'⚠ These components use StyleX and require a StyleX compiler in your build.',
|
|
410
|
-
);
|
|
411
|
-
humanLog(
|
|
412
|
-
' Without one they render unstyled (no error). See setup per framework:',
|
|
413
|
-
);
|
|
414
|
-
humanLog(` ${getRunPrefix()} astryx docs styling`);
|
|
415
|
-
humanLog(
|
|
416
|
-
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —',
|
|
417
|
-
);
|
|
418
|
-
humanLog(
|
|
419
|
-
' use an SWC-based StyleX transform instead (covered in the guide).',
|
|
420
|
-
);
|
|
421
|
-
humanLog('');
|
|
422
|
-
}
|
|
423
|
-
|
|
424
390
|
// Maintainer feedback note. If we couldn't swizzle cleanly, the team
|
|
425
391
|
// wants to know — point users at the issue tracker. Skipped when the
|
|
426
392
|
// owning package ships no issues URL.
|
|
@@ -277,70 +277,3 @@ describe('swizzle — ambiguous ownership', () => {
|
|
|
277
277
|
expect(out).toContain(`from '@astryxdesign/core/theme'`);
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Build a fake @astryxdesign/core with a component that imports StyleX directly
|
|
283
|
-
* (so the swizzle StyleX-build note should fire) and one that doesn't.
|
|
284
|
-
*/
|
|
285
|
-
function buildStyleXCore(project) {
|
|
286
|
-
const core = path.join(project, 'node_modules', '@astryxdesign', 'core');
|
|
287
|
-
// StyleX component.
|
|
288
|
-
const styledDir = path.join(core, 'src', 'Styled');
|
|
289
|
-
fs.mkdirSync(styledDir, {recursive: true});
|
|
290
|
-
fs.writeFileSync(
|
|
291
|
-
path.join(core, 'package.json'),
|
|
292
|
-
'{"name":"@astryxdesign/core","version":"0.0.13"}',
|
|
293
|
-
);
|
|
294
|
-
fs.writeFileSync(
|
|
295
|
-
path.join(styledDir, 'Styled.tsx'),
|
|
296
|
-
[
|
|
297
|
-
`import * as stylex from '@stylexjs/stylex';`,
|
|
298
|
-
`const styles = stylex.create({base: {color: 'red'}});`,
|
|
299
|
-
`export const Styled = () => null;`,
|
|
300
|
-
'',
|
|
301
|
-
].join('\n'),
|
|
302
|
-
);
|
|
303
|
-
// Plain component (no StyleX).
|
|
304
|
-
const plainDir = path.join(core, 'src', 'Plain');
|
|
305
|
-
fs.mkdirSync(plainDir, {recursive: true});
|
|
306
|
-
fs.writeFileSync(
|
|
307
|
-
path.join(plainDir, 'Plain.tsx'),
|
|
308
|
-
`export const Plain = () => null;\n`,
|
|
309
|
-
);
|
|
310
|
-
return core;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
314
|
-
it('reports usesStyleX and prints a setup note for StyleX components', () => {
|
|
315
|
-
buildStyleXCore(project);
|
|
316
|
-
writeProjectPackageJson(project);
|
|
317
|
-
|
|
318
|
-
// JSON payload carries the machine-readable flag.
|
|
319
|
-
const jsonResult = runCli(['--json', 'swizzle', 'Styled', '-f'], project);
|
|
320
|
-
expect(jsonResult.code).toBe(0);
|
|
321
|
-
const env = JSON.parse(jsonResult.stdout);
|
|
322
|
-
expect(env.data.usesStyleX).toBe(true);
|
|
323
|
-
|
|
324
|
-
// Human output surfaces the compiler requirement + Next.js caveat.
|
|
325
|
-
const humanResult = runCli(['swizzle', 'Styled', '-f'], project);
|
|
326
|
-
expect(humanResult.code).toBe(0);
|
|
327
|
-
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
328
|
-
expect(humanResult.stdout).toMatch(/unstyled/i);
|
|
329
|
-
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
330
|
-
expect(humanResult.stdout).toMatch(/astryx docs styling/);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it('does not print the StyleX note for components without StyleX', () => {
|
|
334
|
-
buildStyleXCore(project);
|
|
335
|
-
writeProjectPackageJson(project);
|
|
336
|
-
|
|
337
|
-
const jsonResult = runCli(['--json', 'swizzle', 'Plain', '-f'], project);
|
|
338
|
-
expect(jsonResult.code).toBe(0);
|
|
339
|
-
const env = JSON.parse(jsonResult.stdout);
|
|
340
|
-
expect(env.data.usesStyleX).toBe(false);
|
|
341
|
-
|
|
342
|
-
const humanResult = runCli(['swizzle', 'Plain', '-f'], project);
|
|
343
|
-
expect(humanResult.code).toBe(0);
|
|
344
|
-
expect(humanResult.stdout).not.toMatch(/StyleX compiler/i);
|
|
345
|
-
});
|
|
346
|
-
});
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioCircleImage() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={300}>
|
|
11
|
-
<AspectRatio ratio={1} shape="ellipse"
|
|
11
|
+
<AspectRatio ratio={1} shape="ellipse">
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
|
|
14
14
|
alt="Circular image"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -25,11 +25,16 @@ export default function AspectRatioImageGallery() {
|
|
|
25
25
|
<Center width={600}>
|
|
26
26
|
<Grid columns={3} gap={4} width="100%">
|
|
27
27
|
{images.map(({id, alt}) => (
|
|
28
|
-
<AspectRatio key={id} ratio={4 / 3}
|
|
28
|
+
<AspectRatio key={id} ratio={4 / 3}>
|
|
29
29
|
<img
|
|
30
30
|
src="https://lookaside.facebook.com/assets/astryx/illustrative-horizontal-1.png"
|
|
31
31
|
alt={alt}
|
|
32
|
-
style={{
|
|
32
|
+
style={{
|
|
33
|
+
width: '100%',
|
|
34
|
+
height: '100%',
|
|
35
|
+
objectFit: 'cover',
|
|
36
|
+
borderRadius: 8,
|
|
37
|
+
}}
|
|
33
38
|
/>
|
|
34
39
|
</AspectRatio>
|
|
35
40
|
))}
|
|
@@ -34,13 +34,16 @@ export default function AspectRatioShowcase() {
|
|
|
34
34
|
<VStack key={label} gap={2} hAlign="center">
|
|
35
35
|
<AspectRatio
|
|
36
36
|
ratio={ratio}
|
|
37
|
-
fit="cover"
|
|
38
37
|
style={{
|
|
39
38
|
height: 120,
|
|
40
39
|
width: 'auto',
|
|
41
40
|
borderRadius: 'var(--radius-container)',
|
|
42
41
|
}}>
|
|
43
|
-
<img
|
|
42
|
+
<img
|
|
43
|
+
src={src}
|
|
44
|
+
alt={alt}
|
|
45
|
+
style={{width: '100%', height: '100%', objectFit: 'cover'}}
|
|
46
|
+
/>
|
|
44
47
|
</AspectRatio>
|
|
45
48
|
<Text type="supporting" color="secondary">
|
|
46
49
|
{label}
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioSquareImage() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={300}>
|
|
11
|
-
<AspectRatio ratio={1}
|
|
11
|
+
<AspectRatio ratio={1}>
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
|
|
14
14
|
alt="1:1 square"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioWidescreen() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={600}>
|
|
11
|
-
<AspectRatio ratio={16 / 9}
|
|
11
|
+
<AspectRatio ratio={16 / 9}>
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png"
|
|
14
14
|
alt="16:9 widescreen"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'Code — Terminal',
|
|
8
8
|
displayName: 'Code — Terminal',
|
|
9
9
|
description:
|
|
10
|
-
'A dark terminal-style command block: a bash CodeBlock wrapped in SyntaxTheme with the GitHub Dark preset, copy button on, and no line numbers. Use for shell sessions or CLI output that should read as a terminal even on light pages
|
|
10
|
+
'A dark terminal-style command block: a bash CodeBlock wrapped in SyntaxTheme with the GitHub Dark preset, copy button on, and no line numbers. Use for shell sessions or CLI output that should read as a terminal even on light pages — reach for a dark syntax preset instead of hand-rolling a dark box with custom CSS.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['CodeBlock', 'SyntaxTheme'],
|
|
@@ -2,36 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
|
-
import {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
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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 {
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 {
|
|
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
|
}
|
|
@@ -25,23 +25,21 @@ function AppIcon() {
|
|
|
25
25
|
|
|
26
26
|
export default function NavHeadingMenuShowcase() {
|
|
27
27
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</SideNav>
|
|
45
|
-
</div>
|
|
28
|
+
<SideNav
|
|
29
|
+
header={
|
|
30
|
+
<SideNavHeading
|
|
31
|
+
heading="Acme Platform"
|
|
32
|
+
icon={<AppIcon />}
|
|
33
|
+
menu={
|
|
34
|
+
<NavHeadingMenu size="lg">
|
|
35
|
+
<NavHeadingMenuItem label="Dashboard" href="/dashboard" />
|
|
36
|
+
<NavHeadingMenuItem label="Analytics" href="/analytics" />
|
|
37
|
+
<NavHeadingMenuItem label="Settings" href="/settings" />
|
|
38
|
+
</NavHeadingMenu>
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
}>
|
|
42
|
+
{null}
|
|
43
|
+
</SideNav>
|
|
46
44
|
);
|
|
47
45
|
}
|