@astryxdesign/cli 0.1.0-canary.f94dd07 → 0.1.0

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.
@@ -2,8 +2,14 @@
2
2
 
3
3
  'use client';
4
4
 
5
- import {useCallback, useState, useMemo} from 'react';
5
+ import {useState, useMemo} from 'react';
6
6
  import * as stylex from '@stylexjs/stylex';
7
+ import {
8
+ SideNav,
9
+ SideNavHeading,
10
+ SideNavItem,
11
+ SideNavSection,
12
+ } from '@astryxdesign/core/SideNav';
7
13
  import {Heading, Text} from '@astryxdesign/core/Text';
8
14
  import {Button} from '@astryxdesign/core/Button';
9
15
  import {IconButton} from '@astryxdesign/core/IconButton';
@@ -14,10 +20,8 @@ import {Token} from '@astryxdesign/core/Token';
14
20
  import {Banner} from '@astryxdesign/core/Banner';
15
21
  import {CodeBlock} from '@astryxdesign/core/CodeBlock';
16
22
  import {TabList, Tab} from '@astryxdesign/core/TabList';
17
- import {Selector} from '@astryxdesign/core/Selector';
18
23
  import {HStack, VStack, StackItem} from '@astryxdesign/core/Stack';
19
24
  import {Layout, LayoutContent, LayoutPanel} from '@astryxdesign/core/Layout';
20
- import {useMediaQuery} from '@astryxdesign/core/hooks';
21
25
  import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';
22
26
  import {Divider} from '@astryxdesign/core/Divider';
23
27
  import {Tooltip} from '@astryxdesign/core/Tooltip';
@@ -25,7 +29,6 @@ import {Table, pixel} from '@astryxdesign/core/Table';
25
29
  import {Icon} from '@astryxdesign/core/Icon';
26
30
  import {Section} from '@astryxdesign/core/Section';
27
31
  import {Center} from '@astryxdesign/core/Center';
28
- import {Outline, type OutlineItem} from '@astryxdesign/core/Outline';
29
32
  import {
30
33
  ArrowTopRightOnSquareIcon,
31
34
  ArrowsPointingOutIcon,
@@ -34,25 +37,8 @@ import {
34
37
 
35
38
  const styles = stylex.create({
36
39
  tabListFlush: {marginInlineStart: '-12px'},
37
- outlinePanel: {
38
- position: 'sticky',
39
- top: 24,
40
- alignSelf: 'start',
41
- paddingBlockStart: 120,
42
- },
43
40
  });
44
41
 
45
- const COMPONENT_OUTLINE_ITEMS: OutlineItem[] = [
46
- {id: 'usage', label: 'Usage', level: 2},
47
- {id: 'best-practices', label: 'Best practices', level: 3},
48
- {id: 'examples', label: 'Examples', level: 2},
49
- ];
50
-
51
- const COMPONENT_OUTLINE_OPTIONS = COMPONENT_OUTLINE_ITEMS.map(item => ({
52
- value: item.id,
53
- label: item.label,
54
- }));
55
-
56
42
  // ---------------------------------------------------------------------------
57
43
  // DialogPreview — stateful dialog preview for component previews
58
44
  // ---------------------------------------------------------------------------
@@ -507,21 +493,14 @@ function getComponentDocs(key: string) {
507
493
  // ComponentDetailView
508
494
  // ---------------------------------------------------------------------------
509
495
 
510
- function ComponentDetailView({activeNav}: {activeNav: string}) {
496
+ function ComponentDetailView({
497
+ activeNav,
498
+ nav,
499
+ }: {
500
+ activeNav: string;
501
+ nav: React.ReactNode;
502
+ }) {
511
503
  const [exampleTabs, setExampleTabs] = useState<Record<string, string>>({});
512
- const [activeId, setActiveId] = useState<string | undefined>(
513
- COMPONENT_OUTLINE_ITEMS[0]?.id,
514
- );
515
- const isMobile = useMediaQuery('(max-width: 768px)');
516
-
517
- const scrollToId = useCallback((id: string) => {
518
- setActiveId(id);
519
- const target = document.getElementById(id);
520
- if (target != null) {
521
- target.scrollIntoView({behavior: 'smooth', block: 'start'});
522
- window.history.pushState(null, '', `#${id}`);
523
- }
524
- }, []);
525
504
 
526
505
  const EXAMPLE_PREVIEWS: Record<string, React.ReactNode[]> = {
527
506
  button: [
@@ -577,42 +556,25 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
577
556
 
578
557
  return (
579
558
  <Layout
580
- height="auto"
559
+ height="fill"
581
560
  contentWidth={960}
582
- end={
583
- isMobile ? undefined : (
584
- <LayoutPanel
585
- isScrollable={false}
586
- label="On this page"
587
- role="complementary"
588
- xstyle={styles.outlinePanel}>
589
- <Outline
590
- items={COMPONENT_OUTLINE_ITEMS}
591
- onActiveIdChange={setActiveId}
592
- />
593
- </LayoutPanel>
594
- )
561
+ start={
562
+ <LayoutPanel hasDivider padding={0}>
563
+ {nav}
564
+ </LayoutPanel>
595
565
  }
596
566
  content={
597
- <LayoutContent isScrollable={false} padding={8}>
567
+ <LayoutContent padding={8}>
598
568
  <VStack gap={8}>
599
569
  <VStack gap={2}>
600
570
  <Text type="display-1">{getComponentName(activeNav)}</Text>
601
571
  <Text type="supporting" color="secondary">
602
572
  March 30, 2026 · Updated 5:40 p.m. PST
603
573
  </Text>
604
- {isMobile && (
605
- <Selector
606
- label="On this page"
607
- isLabelHidden
608
- options={COMPONENT_OUTLINE_OPTIONS}
609
- value={activeId}
610
- onChange={scrollToId}
611
- width="100%"
612
- />
613
- )}
614
574
  </VStack>
615
575
 
576
+ <Divider />
577
+
616
578
  <Card variant="muted" padding={0}>
617
579
  <Center height={360}>
618
580
  {COMPONENT_PREVIEWS[activeNav] ?? (
@@ -624,18 +586,13 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
624
586
  </Card>
625
587
 
626
588
  <VStack gap={4}>
627
- <Heading id="usage" level={2}>
628
- Usage
629
- </Heading>
589
+ <Heading level={2}>Usage</Heading>
630
590
  <Text type="large" weight="normal">
631
591
  {docs.usage}
632
592
  </Text>
633
- <Heading id="best-practices" level={3}>
634
- Best practices
635
- </Heading>
593
+ <Heading level={3}>Best practices</Heading>
636
594
  <Table
637
595
  data={docs.bestPractices as Record<string, unknown>[]}
638
- dividers="none"
639
596
  columns={[
640
597
  {
641
598
  key: 'type',
@@ -659,15 +616,14 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
659
616
  },
660
617
  ]}
661
618
  density="spacious"
619
+ dividers="rows"
662
620
  />
663
621
  </VStack>
664
622
 
665
623
  <Divider />
666
624
 
667
625
  <VStack gap={4}>
668
- <Heading id="examples" level={2}>
669
- Examples
670
- </Heading>
626
+ <Heading level={2}>Examples</Heading>
671
627
  <Text type="large" weight="normal">
672
628
  Explore common configurations, variations, and states for this
673
629
  component.
@@ -719,10 +675,7 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
719
675
  <TabList
720
676
  value={activeTab}
721
677
  onChange={value =>
722
- setExampleTabs(prev => ({
723
- ...prev,
724
- [tabKey]: value,
725
- }))
678
+ setExampleTabs(prev => ({...prev, [tabKey]: value}))
726
679
  }
727
680
  size="sm"
728
681
  xstyle={styles.tabListFlush}>
@@ -732,11 +685,7 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
732
685
  {activeTab === 'description' ? (
733
686
  <Text type="body">{example.description}</Text>
734
687
  ) : (
735
- <CodeBlock
736
- code={example.code}
737
- language="tsx"
738
- width="100%"
739
- />
688
+ <CodeBlock code={example.code} language="tsx" />
740
689
  )}
741
690
  </VStack>
742
691
  </Section>
@@ -756,5 +705,31 @@ function ComponentDetailView({activeNav}: {activeNav: string}) {
756
705
  // ---------------------------------------------------------------------------
757
706
 
758
707
  export default function DesignDocumentationPage() {
759
- return <ComponentDetailView activeNav="button" />;
708
+ const [activePage, setActivePage] = useState<string>('button');
709
+
710
+ return (
711
+ <ComponentDetailView
712
+ activeNav={activePage}
713
+ nav={
714
+ <SideNav header={<SideNavHeading heading="Product Name" />}>
715
+ {COMPONENT_CATEGORIES.map(category => (
716
+ <SideNavSection key={category.label} title={category.label}>
717
+ {category.items.map(item => (
718
+ <SideNavItem
719
+ key={item.key}
720
+ label={item.name}
721
+ isSelected={activePage === item.key}
722
+ onClick={
723
+ item.key === 'button'
724
+ ? () => setActivePage(item.key)
725
+ : undefined
726
+ }
727
+ />
728
+ ))}
729
+ </SideNavSection>
730
+ ))}
731
+ </SideNav>
732
+ }
733
+ />
734
+ );
760
735
  }
@@ -2,21 +2,22 @@
2
2
 
3
3
  'use client';
4
4
 
5
- import {useCallback, useState} from 'react';
6
- import * as stylex from '@stylexjs/stylex';
5
+ import {
6
+ SideNav,
7
+ SideNavHeading,
8
+ SideNavItem,
9
+ SideNavSection,
10
+ } from '@astryxdesign/core/SideNav';
7
11
  import {Heading, Text} from '@astryxdesign/core/Text';
8
12
  import {Button} from '@astryxdesign/core/Button';
9
13
  import {Card} from '@astryxdesign/core/Card';
10
14
  import {DropdownMenu} from '@astryxdesign/core/DropdownMenu';
11
15
  import {List, ListItem} from '@astryxdesign/core/List';
12
16
  import {CodeBlock} from '@astryxdesign/core/CodeBlock';
13
- import {Selector} from '@astryxdesign/core/Selector';
14
17
  import {HStack, VStack, StackItem} from '@astryxdesign/core/Stack';
15
18
  import {Layout, LayoutContent, LayoutPanel} from '@astryxdesign/core/Layout';
16
19
  import {Divider} from '@astryxdesign/core/Divider';
17
20
  import {Icon} from '@astryxdesign/core/Icon';
18
- import {Outline, type OutlineItem} from '@astryxdesign/core/Outline';
19
- import {useMediaQuery} from '@astryxdesign/core/hooks';
20
21
  import {
21
22
  SparklesIcon,
22
23
  ClipboardDocumentIcon,
@@ -27,75 +28,35 @@ import {
27
28
  // Main component
28
29
  // ---------------------------------------------------------------------------
29
30
 
30
- const OUTLINE_ITEMS: OutlineItem[] = [
31
- {id: 'prerequisites', label: 'Prerequisites', level: 2},
32
- {id: 'install-package', label: 'Install the package', level: 2},
33
- {id: 'configure-theming', label: 'Configure theming', level: 2},
34
- {id: 'next-steps', label: 'Next steps', level: 2},
35
- ];
36
-
37
- const OUTLINE_OPTIONS = OUTLINE_ITEMS.map(item => ({
38
- value: item.id,
39
- label: item.label,
40
- }));
41
-
42
- const styles = stylex.create({
43
- outlinePanel: {
44
- position: 'sticky',
45
- top: 24,
46
- alignSelf: 'start',
47
- paddingBlockStart: 120,
48
- },
49
- });
50
-
51
31
  export default function TechnicalDocumentationPage() {
52
- const [activeId, setActiveId] = useState<string | undefined>(
53
- OUTLINE_ITEMS[0]?.id,
54
- );
55
- const isMobile = useMediaQuery('(max-width: 768px)');
56
-
57
- const scrollToId = useCallback((id: string) => {
58
- setActiveId(id);
59
- const target = document.getElementById(id);
60
- if (target != null) {
61
- target.scrollIntoView({behavior: 'smooth', block: 'start'});
62
- window.history.pushState(null, '', `#${id}`);
63
- }
64
- }, []);
65
-
66
32
  return (
67
33
  <Layout
68
- height="auto"
34
+ height="fill"
69
35
  contentWidth={960}
70
- end={
71
- isMobile ? undefined : (
72
- <LayoutPanel
73
- isScrollable={false}
74
- label="On this page"
75
- role="complementary"
76
- xstyle={styles.outlinePanel}>
77
- <Outline items={OUTLINE_ITEMS} onActiveIdChange={setActiveId} />
78
- </LayoutPanel>
79
- )
36
+ start={
37
+ <LayoutPanel hasDivider padding={0}>
38
+ <SideNav header={<SideNavHeading heading="Product Name" />}>
39
+ <SideNavSection title="Navigation" isHeaderHidden>
40
+ <SideNavItem label="Home" />
41
+ <SideNavItem label="Getting started" isSelected />
42
+ </SideNavSection>
43
+ </SideNav>
44
+ </LayoutPanel>
80
45
  }
81
46
  content={
82
- <LayoutContent isScrollable={false} padding={8}>
47
+ <LayoutContent padding={8}>
83
48
  <VStack gap={8}>
84
49
  <VStack gap={2}>
85
- <Text type="display-1">Getting started with Product Name</Text>
50
+ <Text type="display-1">
51
+ Getting started with Product Name
52
+ </Text>
86
53
  <Text type="supporting" color="secondary">
87
54
  Last updated March 30, 2026
88
55
  </Text>
89
- {isMobile && (
90
- <Selector
91
- label="On this page"
92
- isLabelHidden
93
- options={OUTLINE_OPTIONS}
94
- value={activeId}
95
- onChange={scrollToId}
96
- width="100%"
97
- />
98
- )}
56
+ <Text type="body">
57
+ Install the package, configure your theme, and build your first
58
+ component in three steps.
59
+ </Text>
99
60
  </VStack>
100
61
 
101
62
  <Card>
@@ -103,7 +64,11 @@ export default function TechnicalDocumentationPage() {
103
64
  <HStack gap={2} vAlign="center">
104
65
  <StackItem size="fill">
105
66
  <HStack gap={2} vAlign="center">
106
- <Icon icon={SparklesIcon} size="sm" color="secondary" />
67
+ <Icon
68
+ icon={SparklesIcon}
69
+ size="sm"
70
+ color="secondary"
71
+ />
107
72
  <Text type="body" weight="semibold">
108
73
  AI Assistance
109
74
  </Text>
@@ -138,17 +103,15 @@ export default function TechnicalDocumentationPage() {
138
103
  </HStack>
139
104
  <Text type="body" color="secondary">
140
105
  Help me get set up with Product Name. Based on my project, do
141
- the following: 1. Install @astryxdesign/core and the StyleX
142
- compiler. 2. Wrap my app in ThemeProvider. 3. Replace one
143
- existing component with an Astryx equivalent.
106
+ the following: 1. Install @astryxdesign/core and the StyleX compiler.
107
+ 2. Wrap my app in ThemeProvider. 3. Replace one existing
108
+ component with an Astryx equivalent.
144
109
  </Text>
145
110
  </VStack>
146
111
  </Card>
147
112
 
148
113
  <VStack gap={4}>
149
- <Heading id="prerequisites" level={2}>
150
- Prerequisites
151
- </Heading>
114
+ <Heading level={2}>Prerequisites</Heading>
152
115
  <List density="compact" listStyle="disc">
153
116
  <ListItem label="Node.js 18+" />
154
117
  <ListItem label="React 18 or 19" />
@@ -159,9 +122,7 @@ export default function TechnicalDocumentationPage() {
159
122
  <Divider />
160
123
 
161
124
  <VStack gap={4}>
162
- <Heading id="install-package" level={2}>
163
- Install the package
164
- </Heading>
125
+ <Heading level={2}>Install the package</Heading>
165
126
  <Text type="body">
166
127
  Every project starts with installing the core package. This
167
128
  gives you access to all components, tokens, and utilities.
@@ -170,55 +131,54 @@ export default function TechnicalDocumentationPage() {
170
131
  <Text type="body" weight="bold">
171
132
  Step 1: Install the core package
172
133
  </Text>
173
- <CodeBlock
174
- code="npm install @astryxdesign/core"
175
- language="bash"
176
- width="100%"
177
- />
134
+ <Card padding={0}>
135
+ <CodeBlock code="npm install @astryxdesign/core" language="bash" />
136
+ </Card>
178
137
  </VStack>
179
138
  <VStack gap={2}>
180
139
  <Text type="body" weight="bold">
181
140
  Step 2: Add the StyleX compiler
182
141
  </Text>
183
142
  <Text type="body" color="secondary">
184
- Astryx uses StyleX for styling. Add the compiler plugin to
185
- your build configuration.
143
+ Astryx uses StyleX for styling. Add the compiler plugin to your
144
+ build configuration.
186
145
  </Text>
187
- <CodeBlock
188
- code="npm install @stylexjs/babel-plugin"
189
- language="bash"
190
- width="100%"
191
- />
146
+ <Card padding={0}>
147
+ <CodeBlock
148
+ code="npm install @stylexjs/babel-plugin"
149
+ language="bash"
150
+ />
151
+ </Card>
192
152
  </VStack>
193
153
  <VStack gap={2}>
194
154
  <Text type="body" weight="bold">
195
155
  Step 3: Import your first component
196
156
  </Text>
197
- <CodeBlock
198
- code={`import { Button } from '@astryxdesign/core/Button';
157
+ <Card padding={0}>
158
+ <CodeBlock
159
+ code={`import { Button } from '@astryxdesign/core/Button';
199
160
 
200
161
  export default function App() {
201
162
  return <Button label="Hello Astryx" variant="primary" />;
202
163
  }`}
203
- language="tsx"
204
- width="100%"
205
- />
164
+ language="tsx"
165
+ />
166
+ </Card>
206
167
  </VStack>
207
168
  </VStack>
208
169
 
209
170
  <Divider />
210
171
 
211
172
  <VStack gap={4}>
212
- <Heading id="configure-theming" level={2}>
213
- Configure theming
214
- </Heading>
173
+ <Heading level={2}>Configure theming</Heading>
215
174
  <Text type="body">
216
175
  Astryx ships with a default theme that works out of the box. To
217
176
  customize colors, typography, and spacing, wrap your app in a
218
177
  theme provider.
219
178
  </Text>
220
- <CodeBlock
221
- code={`import { ThemeProvider } from '@astryxdesign/core/Theme';
179
+ <Card padding={0}>
180
+ <CodeBlock
181
+ code={`import { ThemeProvider } from '@astryxdesign/core/Theme';
222
182
 
223
183
  export default function App({ children }) {
224
184
  return (
@@ -227,9 +187,9 @@ export default function App({ children }) {
227
187
  </ThemeProvider>
228
188
  );
229
189
  }`}
230
- language="tsx"
231
- width="100%"
232
- />
190
+ language="tsx"
191
+ />
192
+ </Card>
233
193
  <Text type="body" color="secondary">
234
194
  See the theming guide for the full list of customizable tokens.
235
195
  </Text>
@@ -238,9 +198,7 @@ export default function App({ children }) {
238
198
  <Divider />
239
199
 
240
200
  <VStack gap={4}>
241
- <Heading id="next-steps" level={2}>
242
- Next steps
243
- </Heading>
201
+ <Heading level={2}>Next steps</Heading>
244
202
  <List density="compact" listStyle="disc">
245
203
  <ListItem label="Fundamental concepts — How theming, layout, and composition work" />
246
204
  <ListItem label="Component API reference — Props, variants, and examples for every component" />