@astryxdesign/cli 0.7.7-canary.d40b519 → 0.7.7-canary.dfa7ae0

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.
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useGridFocus',
7
+ name: 'useGridFocus — Color Swatch Grid',
8
+ displayName: 'useGridFocus — Color Swatch Grid',
9
+ description:
10
+ 'A color swatch picker in rows of eight with one Tab stop. useGridFocus moves focus with the arrow keys, Home and End, and Ctrl+Home and Ctrl+End. Each swatch is a button, so Enter or a click picks it.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Card', 'Text', 'Layout'],
14
+ };
@@ -0,0 +1,86 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import {Card} from '@astryxdesign/core/Card';
7
+ import {useGridFocus} from '@astryxdesign/core/hooks';
8
+ import {VStack} from '@astryxdesign/core/Layout';
9
+ import {Text} from '@astryxdesign/core/Text';
10
+
11
+ const COLUMNS = 8;
12
+
13
+ const SWATCHES = [
14
+ {name: 'Red', value: '#e5484d'},
15
+ {name: 'Tomato', value: '#f76b15'},
16
+ {name: 'Amber', value: '#ffc53d'},
17
+ {name: 'Lime', value: '#bdee63'},
18
+ {name: 'Green', value: '#30a46c'},
19
+ {name: 'Teal', value: '#12a594'},
20
+ {name: 'Cyan', value: '#00a2c7'},
21
+ {name: 'Blue', value: '#0090ff'},
22
+ {name: 'Indigo', value: '#3e63dd'},
23
+ {name: 'Violet', value: '#6e56cf'},
24
+ {name: 'Purple', value: '#8e4ec6'},
25
+ {name: 'Plum', value: '#ab4aba'},
26
+ {name: 'Pink', value: '#d6409f'},
27
+ {name: 'Brown', value: '#ad7f58'},
28
+ {name: 'Gray', value: '#8d8d8d'},
29
+ {name: 'Black', value: '#111111'},
30
+ ];
31
+
32
+ const ROWS = Array.from({length: SWATCHES.length / COLUMNS}, (_, row) =>
33
+ SWATCHES.slice(row * COLUMNS, (row + 1) * COLUMNS),
34
+ );
35
+
36
+ export default function UseGridFocusHookUsage() {
37
+ const [selected, setSelected] = useState(SWATCHES[0].name);
38
+ const {gridRef, handleKeyDown, handleFocus} = useGridFocus<HTMLDivElement>({
39
+ columns: COLUMNS,
40
+ cellSelector: '[role="gridcell"]',
41
+ getFocusTarget: cell => cell.querySelector('button'),
42
+ hasRovingTabIndex: true,
43
+ });
44
+
45
+ return (
46
+ <Card padding={4}>
47
+ <VStack gap={3}>
48
+ <Text type="body">Selected: {selected}</Text>
49
+ <div
50
+ ref={gridRef}
51
+ role="grid"
52
+ aria-label="Colors"
53
+ onKeyDown={handleKeyDown}
54
+ onFocus={handleFocus}
55
+ style={{display: 'flex', flexDirection: 'column', gap: 4}}>
56
+ {ROWS.map((row, index) => (
57
+ <div key={index} role="row" style={{display: 'flex', gap: 4}}>
58
+ {row.map(swatch => (
59
+ <div
60
+ key={swatch.name}
61
+ role="gridcell"
62
+ aria-selected={swatch.name === selected}>
63
+ <button
64
+ type="button"
65
+ aria-label={swatch.name}
66
+ aria-pressed={swatch.name === selected}
67
+ onClick={() => setSelected(swatch.name)}
68
+ style={{
69
+ width: 28,
70
+ height: 28,
71
+ border: 'none',
72
+ boxShadow:
73
+ 'inset 0 0 0 1px var(--color-border-emphasized)',
74
+ borderRadius: 4,
75
+ background: swatch.value,
76
+ }}
77
+ />
78
+ </div>
79
+ ))}
80
+ </div>
81
+ ))}
82
+ </div>
83
+ </VStack>
84
+ </Card>
85
+ );
86
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useOverflow',
7
+ name: 'useOverflow — Editor Toolbar',
8
+ displayName: 'useOverflow — Editor Toolbar',
9
+ description:
10
+ 'Resize the card: useOverflow moves the toolbar actions that do not fit into a More menu, and shows them again when the card gets wider.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['Card', 'Button', 'DropdownMenu'],
14
+ };
@@ -0,0 +1,89 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import * as stylex from '@stylexjs/stylex';
6
+ import {useOverflow} from '@astryxdesign/core/hooks';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {Card} from '@astryxdesign/core/Card';
9
+ import {DropdownMenu} from '@astryxdesign/core/DropdownMenu';
10
+
11
+ const actions = [
12
+ 'Bold',
13
+ 'Italic',
14
+ 'Underline',
15
+ 'Strikethrough',
16
+ 'Link',
17
+ 'Quote',
18
+ 'Code',
19
+ 'Clear formatting',
20
+ ];
21
+
22
+ const GAP = 4;
23
+
24
+ const styles = stylex.create({
25
+ box: {
26
+ resize: 'horizontal',
27
+ overflow: 'hidden',
28
+ width: 480,
29
+ minWidth: 120,
30
+ maxWidth: '100%',
31
+ },
32
+ row: {
33
+ display: 'flex',
34
+ gap: GAP,
35
+ },
36
+ // Takes no space and paints nothing, so the hook measures every item
37
+ // without a flicker. Do not use display: none, which stops measurement.
38
+ measure: {
39
+ position: 'absolute',
40
+ visibility: 'hidden',
41
+ height: 0,
42
+ overflow: 'hidden',
43
+ whiteSpace: 'nowrap',
44
+ pointerEvents: 'none',
45
+ },
46
+ });
47
+
48
+ function MoreMenu({items}: {items: string[]}) {
49
+ return (
50
+ <DropdownMenu
51
+ button={{label: 'More', variant: 'ghost', size: 'sm'}}
52
+ items={items.map(label => ({label}))}
53
+ />
54
+ );
55
+ }
56
+
57
+ export default function UseOverflowHookUsage() {
58
+ const {containerRef, measureRef, visibleCount, hasOverflow} = useOverflow(
59
+ actions.length,
60
+ {gap: GAP},
61
+ );
62
+
63
+ return (
64
+ <Card padding={2} xstyle={styles.box}>
65
+ <div
66
+ ref={measureRef}
67
+ aria-hidden="true"
68
+ inert
69
+ {...stylex.props(styles.row, styles.measure)}>
70
+ {actions.map(label => (
71
+ <Button key={label} label={label} variant="ghost" size="sm" />
72
+ ))}
73
+ <div data-overflow-indicator>
74
+ <MoreMenu items={actions} />
75
+ </div>
76
+ </div>
77
+ <div
78
+ ref={containerRef}
79
+ role="group"
80
+ aria-label="Text formatting"
81
+ {...stylex.props(styles.row)}>
82
+ {actions.slice(0, visibleCount).map(label => (
83
+ <Button key={label} label={label} variant="ghost" size="sm" />
84
+ ))}
85
+ {hasOverflow && <MoreMenu items={actions.slice(visibleCount)} />}
86
+ </div>
87
+ </Card>
88
+ );
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.7-canary.d40b519",
3
+ "version": "0.7.7-canary.dfa7ae0",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "0.7.7-canary.d40b519",
128
- "@astryxdesign/core": "0.7.7-canary.d40b519",
129
- "@astryxdesign/lab": "0.7.7-canary.d40b519",
130
- "@astryxdesign/theme-neutral": "0.7.7-canary.d40b519"
127
+ "@astryxdesign/charts": "0.7.7-canary.dfa7ae0",
128
+ "@astryxdesign/core": "0.7.7-canary.dfa7ae0",
129
+ "@astryxdesign/lab": "0.7.7-canary.dfa7ae0",
130
+ "@astryxdesign/theme-neutral": "0.7.7-canary.dfa7ae0"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "0.7.7-canary.d40b519",
148
- "@astryxdesign/core": "0.7.7-canary.d40b519",
149
- "@astryxdesign/lab": "0.7.7-canary.d40b519",
150
- "@astryxdesign/theme-neutral": "0.7.7-canary.d40b519",
147
+ "@astryxdesign/charts": "0.7.7-canary.dfa7ae0",
148
+ "@astryxdesign/core": "0.7.7-canary.dfa7ae0",
149
+ "@astryxdesign/lab": "0.7.7-canary.dfa7ae0",
150
+ "@astryxdesign/theme-neutral": "0.7.7-canary.dfa7ae0",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",