@astryxdesign/cli 0.7.5-canary.dbcfc30 → 0.7.5-canary.dc5a8cf
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/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +190 -95
- package/api/theme/build/build.project-core.test.mjs +63 -8
- package/api/theme/build/build.test.mjs +77 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -1
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +13 -6
- package/assets/theme.template.ts +18 -5
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/package.json +9 -9
|
@@ -101,11 +101,92 @@ export const brandTheme = defineTheme({
|
|
|
101
101
|
},
|
|
102
102
|
});`,
|
|
103
103
|
},
|
|
104
|
+
{
|
|
105
|
+
type: 'prose',
|
|
106
|
+
text: "An entry can also be a function of the request, so the theme maps Icon's size to its icon library's own props or artwork. `Icon` calls it with `{size, variant}`, where `size` is the size it renders at (`xsm`, `sm`, `md`, or `lg`: an explicit `size`, else the owning component's default, else `md`). Reads that return one node — `getIcon()`, `useIcon()`, `getIconRegistry()`, and the theme's `icons` field — call it with `{size: 'md'}`. The same entry shape works in `registerIcons()`.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'code',
|
|
110
|
+
lang: 'tsx',
|
|
111
|
+
label: 'A size-aware icon entry',
|
|
112
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
113
|
+
import {Info} from 'lucide-react';
|
|
114
|
+
|
|
115
|
+
export const brandTheme = defineTheme({
|
|
116
|
+
name: 'brand',
|
|
117
|
+
icons: {
|
|
118
|
+
// A heavier stroke keeps the small size legible.
|
|
119
|
+
info: ({size}) => <Info strokeWidth={size === 'sm' || size === 'xsm' ? 2.5 : 2} />,
|
|
120
|
+
},
|
|
121
|
+
});`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'Keep the function pure and synchronous: it computes its result from the request only, with no hooks, DOM or SVG measurement, browser globals, network access, mutable module state, or side effects. Its result is final. Returning `null` draws no glyph instead of falling back to a registered or built-in icon, while a `null` or `undefined` node entry still falls back. A child theme that sets an entry for a key replaces the inherited entry for that key.',
|
|
126
|
+
},
|
|
104
127
|
],
|
|
105
128
|
},
|
|
106
129
|
{
|
|
107
|
-
title: '
|
|
130
|
+
title: 'Icon Variants',
|
|
108
131
|
category: 'foundations',
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'prose',
|
|
135
|
+
text: "A theme lists the icon variant names it supports once, with `iconVariants` in `defineTheme()`. The list belongs to the whole theme, never to one icon, and Astryx defines no names of its own. Inside `defineTheme`, an entry function receives `variant` typed as the listed names, or `undefined`, so a misspelled name is a type error. An entry that receives `undefined` draws its normal artwork.",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'code',
|
|
139
|
+
lang: 'tsx',
|
|
140
|
+
label: 'Listing variants and mapping them to artwork',
|
|
141
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
142
|
+
import {InfoFilledIcon, InfoIcon} from './brand-icons';
|
|
143
|
+
|
|
144
|
+
export const brandTheme = defineTheme({
|
|
145
|
+
name: 'brand',
|
|
146
|
+
iconVariants: ['outline', 'filled'],
|
|
147
|
+
icons: {
|
|
148
|
+
info: ({size, variant}) =>
|
|
149
|
+
variant === 'filled' ? <InfoFilledIcon /> : <InfoIcon bold={size === 'sm'} />,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
brandTheme.iconVariants; // ['outline', 'filled']`,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'prose',
|
|
157
|
+
text: 'A theme that `extends` another inherits its list unless it sets its own; a list it sets replaces the inherited one instead of merging with it.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'prose',
|
|
161
|
+
text: "Request a variant with `Icon`'s `variant` prop. The entry receives it only when the active theme lists it; an entry the theme inherited also needs the theme that defined it to list it. Otherwise the entry receives `undefined` and draws its normal artwork, so an unlisted variant never breaks rendering. A `registerIcons()` entry receives the variants the active theme lists, and a node entry draws the same node for every variant. An icon component passed directly to `Icon` never receives `variant`, and `variant` is never written to the DOM: it selects artwork, so there is no theming selector for it.",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'code',
|
|
165
|
+
lang: 'tsx',
|
|
166
|
+
label: 'Requesting a variant',
|
|
167
|
+
code: `<Icon icon="info" variant="filled" /> // brandTheme: the filled artwork
|
|
168
|
+
<Icon icon="info" /> // the normal artwork`,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: 'prose',
|
|
172
|
+
text: 'An application declares the variant names it uses by augmenting `IconVariantMap` from `@astryxdesign/core/Icon`. `IconVariant` is those names, and an entry passed to `registerIcons()` receives `variant` typed as `IconVariant`.',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'code',
|
|
176
|
+
lang: 'ts',
|
|
177
|
+
label: 'Declaring the variant names an application uses',
|
|
178
|
+
code: `declare module '@astryxdesign/core/Icon' {
|
|
179
|
+
interface IconVariantMap {
|
|
180
|
+
outline: true;
|
|
181
|
+
filled: true;
|
|
182
|
+
}
|
|
183
|
+
}`,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
title: 'Component and Library Icons',
|
|
189
|
+
category: 'foundations',
|
|
109
190
|
content: [
|
|
110
191
|
{
|
|
111
192
|
type: 'prose',
|
|
@@ -21,6 +21,14 @@ export const docsDense = {
|
|
|
21
21
|
{type: 'prose', text: "new palette: `astryx theme palette generate palette.config.json --out palette.generated.ts` → review + commit module and receipt → `import {palette} from './palette.generated';` → map semantic tokens to stable stops such as `palette.neutral.light[100]` / `palette.neutral.dark[15]`. regeneration updates mapped roles; generation does not rewrite the theme."},
|
|
22
22
|
],
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
section: 'Icon sizes',
|
|
26
|
+
title: 'Icon sizes',
|
|
27
|
+
content: [
|
|
28
|
+
{type: 'prose', text: "theme sets each Icon size's glyph dimension: `width` + `height` on `components.icon['size:sm']` (or xsm/md/lg); semantic names + SVG components alike. px or rem only: a semantic icon takes its font size from the dimension, so em also grows its box. unstyled: xsm/sm/md/lg = 12/16/20/24px at 16px root, scale w/ root font size (rem keeps it). size names are fixed."},
|
|
29
|
+
null,
|
|
30
|
+
],
|
|
31
|
+
},
|
|
24
32
|
{
|
|
25
33
|
section: 'Dark mode',
|
|
26
34
|
title: 'Dark mode',
|
|
@@ -53,6 +53,22 @@ export const docs = {
|
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
id: 'icon-sizes',
|
|
58
|
+
title: 'Icon sizes',
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'prose',
|
|
62
|
+
text: "A theme sets the dimension of each Icon size in its stylesheet: `width` and `height` on `components.icon['size:sm']` (or `xsm`, `md`, `lg`) resize that size's glyph, for semantic icon names and SVG components passed to `Icon` alike. Give the dimension in `px` or `rem`: a semantic icon takes its font size from it, so an `em` value would also grow its box. A size the theme leaves alone stays 12, 16, 20, or 24px at a 16px root (`xsm`, `sm`, `md`, `lg`) and scales with the root font size; `rem` keeps that scaling. The four size names are fixed.",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'code',
|
|
66
|
+
lang: 'tsx',
|
|
67
|
+
label: 'Set Icon size dimensions',
|
|
68
|
+
code: "const brandTheme = defineTheme({\n name: 'brand',\n components: {\n icon: {\n 'size:sm': {width: '1.125rem', height: '1.125rem'},\n 'size:lg': {width: '1.75rem', height: '1.75rem'},\n },\n },\n});",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
56
72
|
{
|
|
57
73
|
id: 'light-dark-mode',
|
|
58
74
|
title: 'Dark mode',
|
|
@@ -25,6 +25,17 @@ export const docsZh = {
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
section: 'Icon sizes',
|
|
30
|
+
title: '图标尺寸',
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'prose',
|
|
34
|
+
text: "主题在样式表中设置每个 Icon 尺寸的大小:在 `components.icon['size:sm']`(或 `xsm`、`md`、`lg`)上设置 `width` 和 `height`,即可调整该尺寸的图标,语义图标名称和直接传给 `Icon` 的 SVG 组件都适用。请使用 `px` 或 `rem` 设置尺寸:语义图标会据此设置自身的字号,因此 `em` 值也会放大它的外框。主题未设置的尺寸在 16px 根字号下保持 12、16、20 或 24px(`xsm`、`sm`、`md`、`lg`),并随根字号缩放;`rem` 可保留这种缩放。四个尺寸名称是固定的。",
|
|
35
|
+
},
|
|
36
|
+
null,
|
|
37
|
+
],
|
|
38
|
+
},
|
|
28
39
|
{
|
|
29
40
|
section: 'Dark mode',
|
|
30
41
|
title: '深色模式',
|
package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
export const doc = {
|
|
5
5
|
type: 'block',
|
|
6
6
|
exampleFor: 'BottomSheetSwitcher',
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
alsoExampleFor: ['BottomSheet'],
|
|
8
|
+
// The published registry identity predates the rewrite; keep it.
|
|
9
|
+
registry: {slug: 'review-flow'},
|
|
10
|
+
name: 'Bottom Sheet — Review flow',
|
|
11
|
+
displayName: 'Bottom Sheet — Review flow',
|
|
9
12
|
description:
|
|
10
|
-
'A two-step form flow
|
|
13
|
+
'A two-step form flow of two standalone sheets driven by one state value: Continue replaces the review step with the confirmation in place, and Back returns.',
|
|
11
14
|
isReady: true,
|
|
12
15
|
isShowcase: false,
|
|
13
16
|
aspectRatio: 3 / 4,
|
|
14
17
|
componentsUsed: [
|
|
15
18
|
'BottomSheet',
|
|
16
|
-
'BottomSheetSwitcher',
|
|
17
19
|
'Button',
|
|
18
20
|
'Heading',
|
|
19
21
|
'Section',
|
|
@@ -3,73 +3,79 @@
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
5
|
import {useState} from 'react';
|
|
6
|
-
import {BottomSheet
|
|
6
|
+
import {BottomSheet} from '@astryxdesign/core/BottomSheet';
|
|
7
7
|
import {Button} from '@astryxdesign/core/Button';
|
|
8
8
|
import {Heading} from '@astryxdesign/core/Heading';
|
|
9
9
|
import {Section} from '@astryxdesign/core/Section';
|
|
10
10
|
import {HStack, VStack} from '@astryxdesign/core/Stack';
|
|
11
11
|
import {Text} from '@astryxdesign/core/Text';
|
|
12
12
|
|
|
13
|
+
type Step = 'review' | 'confirm' | null;
|
|
14
|
+
|
|
13
15
|
export default function BottomSheetSwitcherReviewFlow() {
|
|
14
|
-
|
|
16
|
+
// One state value names the open step; Continue and Back close one sheet
|
|
17
|
+
// and open the other in the same update, which replaces it in place.
|
|
18
|
+
const [step, setStep] = useState<Step>(null);
|
|
19
|
+
// Clear the step only if it is still the open one: a step that closes
|
|
20
|
+
// because the person moved on must not undo the move.
|
|
21
|
+
const close = (own: Step) => (isOpen: boolean) => {
|
|
22
|
+
if (!isOpen) {
|
|
23
|
+
setStep(current => (current === own ? null : current));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
15
26
|
|
|
16
27
|
return (
|
|
17
28
|
<>
|
|
18
|
-
<Button
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<VStack gap={1}>
|
|
33
|
-
<Heading level={3}>Review settings</Heading>
|
|
34
|
-
<Text type="supporting" color="secondary">
|
|
35
|
-
Daily summaries will be sent by email.
|
|
36
|
-
</Text>
|
|
37
|
-
</VStack>
|
|
38
|
-
<HStack gap={2} hAlign="end">
|
|
39
|
-
<Button
|
|
40
|
-
label="Cancel"
|
|
41
|
-
variant="secondary"
|
|
42
|
-
onClick={() => setActiveSheet(null)}
|
|
43
|
-
/>
|
|
44
|
-
<Button
|
|
45
|
-
label="Continue"
|
|
46
|
-
onClick={() => setActiveSheet('confirm')}
|
|
47
|
-
/>
|
|
48
|
-
</HStack>
|
|
29
|
+
<Button label="Review settings" onClick={() => setStep('review')} />
|
|
30
|
+
<BottomSheet
|
|
31
|
+
isOpen={step === 'review'}
|
|
32
|
+
onOpenChange={close('review')}
|
|
33
|
+
label="Review notification settings"
|
|
34
|
+
height="hug"
|
|
35
|
+
purpose="form">
|
|
36
|
+
<Section padding={4}>
|
|
37
|
+
<VStack gap={4}>
|
|
38
|
+
<VStack gap={1}>
|
|
39
|
+
<Heading level={3}>Review settings</Heading>
|
|
40
|
+
<Text type="supporting" color="secondary">
|
|
41
|
+
Daily summaries will be sent by email.
|
|
42
|
+
</Text>
|
|
49
43
|
</VStack>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
44
|
+
<HStack gap={2} hAlign="end">
|
|
45
|
+
<Button
|
|
46
|
+
label="Cancel"
|
|
47
|
+
variant="secondary"
|
|
48
|
+
onClick={() => setStep(null)}
|
|
49
|
+
/>
|
|
50
|
+
<Button label="Continue" onClick={() => setStep('confirm')} />
|
|
51
|
+
</HStack>
|
|
52
|
+
</VStack>
|
|
53
|
+
</Section>
|
|
54
|
+
</BottomSheet>
|
|
55
|
+
<BottomSheet
|
|
56
|
+
isOpen={step === 'confirm'}
|
|
57
|
+
onOpenChange={close('confirm')}
|
|
58
|
+
label="Confirm settings"
|
|
59
|
+
height="hug">
|
|
60
|
+
<Section padding={4}>
|
|
61
|
+
<VStack gap={4}>
|
|
62
|
+
<VStack gap={1}>
|
|
63
|
+
<Heading level={3}>Confirm settings</Heading>
|
|
64
|
+
<Text type="supporting" color="secondary">
|
|
65
|
+
Your notification settings are ready to save.
|
|
66
|
+
</Text>
|
|
69
67
|
</VStack>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
<HStack gap={2} hAlign="end">
|
|
69
|
+
<Button
|
|
70
|
+
label="Back"
|
|
71
|
+
variant="secondary"
|
|
72
|
+
onClick={() => setStep('review')}
|
|
73
|
+
/>
|
|
74
|
+
<Button label="Save" onClick={() => setStep(null)} />
|
|
75
|
+
</HStack>
|
|
76
|
+
</VStack>
|
|
77
|
+
</Section>
|
|
78
|
+
</BottomSheet>
|
|
73
79
|
</>
|
|
74
80
|
);
|
|
75
81
|
}
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
export const doc = {
|
|
5
5
|
type: 'block',
|
|
6
6
|
exampleFor: 'BottomSheetSwitcher',
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
alsoExampleFor: ['BottomSheet'],
|
|
8
|
+
// The published registry identity predates the rewrite; keep it.
|
|
9
|
+
registry: {slug: 'default'},
|
|
10
|
+
name: 'Bottom Sheet — Multi-step flow',
|
|
11
|
+
displayName: 'Bottom Sheet — Multi-step flow',
|
|
9
12
|
description:
|
|
10
|
-
'A three-step flow
|
|
13
|
+
'A three-step flow of standalone sheets of different heights, driven by one state value: moving on replaces the open step in place. This is the replacement for the deprecated BottomSheetSwitcher.',
|
|
11
14
|
isReady: true,
|
|
12
15
|
isShowcase: true,
|
|
13
16
|
aspectRatio: 3 / 4,
|
|
14
17
|
componentsUsed: [
|
|
15
18
|
'BottomSheet',
|
|
16
|
-
'BottomSheetSwitcher',
|
|
17
19
|
'Button',
|
|
18
20
|
'CheckboxInput',
|
|
19
21
|
'Divider',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
5
|
import {useState} from 'react';
|
|
6
|
-
import {BottomSheet
|
|
6
|
+
import {BottomSheet} from '@astryxdesign/core/BottomSheet';
|
|
7
7
|
import {Button} from '@astryxdesign/core/Button';
|
|
8
8
|
import {CheckboxInput} from '@astryxdesign/core/CheckboxInput';
|
|
9
9
|
import {Divider} from '@astryxdesign/core/Divider';
|
|
@@ -15,20 +15,35 @@ import {RadioList, RadioListItem} from '@astryxdesign/core/RadioList';
|
|
|
15
15
|
|
|
16
16
|
type NotificationSheetHeight = 'hug' | 'capped';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Each step is a standalone sheet. Closing the open step and opening the
|
|
20
|
+
* next one in the same update (one `step` state value) replaces it in place.
|
|
21
|
+
*/
|
|
22
|
+
interface StepSheetProps {
|
|
23
|
+
isOpen: boolean;
|
|
24
|
+
onOpenChange: (isOpen: boolean) => void;
|
|
25
|
+
hasScrim: boolean;
|
|
19
26
|
height: NotificationSheetHeight;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface NotificationOverviewSheetProps extends StepSheetProps {
|
|
20
30
|
onCancel: () => void;
|
|
21
31
|
onContinue: () => void;
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
function NotificationOverviewSheet({
|
|
35
|
+
isOpen,
|
|
36
|
+
onOpenChange,
|
|
37
|
+
hasScrim,
|
|
25
38
|
height,
|
|
26
39
|
onCancel,
|
|
27
40
|
onContinue,
|
|
28
41
|
}: NotificationOverviewSheetProps) {
|
|
29
42
|
return (
|
|
30
43
|
<BottomSheet
|
|
31
|
-
|
|
44
|
+
isOpen={isOpen}
|
|
45
|
+
onOpenChange={onOpenChange}
|
|
46
|
+
hasScrim={hasScrim}
|
|
32
47
|
label="Set up notifications"
|
|
33
48
|
height={height}>
|
|
34
49
|
<Section padding={4}>
|
|
@@ -74,13 +89,15 @@ function NotificationOverviewSheet({
|
|
|
74
89
|
);
|
|
75
90
|
}
|
|
76
91
|
|
|
77
|
-
interface NotificationFrequencySheetProps {
|
|
78
|
-
height: NotificationSheetHeight;
|
|
92
|
+
interface NotificationFrequencySheetProps extends StepSheetProps {
|
|
79
93
|
onBack: () => void;
|
|
80
94
|
onContinue: () => void;
|
|
81
95
|
}
|
|
82
96
|
|
|
83
97
|
function NotificationFrequencySheet({
|
|
98
|
+
isOpen,
|
|
99
|
+
onOpenChange,
|
|
100
|
+
hasScrim,
|
|
84
101
|
height,
|
|
85
102
|
onBack,
|
|
86
103
|
onContinue,
|
|
@@ -89,7 +106,9 @@ function NotificationFrequencySheet({
|
|
|
89
106
|
|
|
90
107
|
return (
|
|
91
108
|
<BottomSheet
|
|
92
|
-
|
|
109
|
+
isOpen={isOpen}
|
|
110
|
+
onOpenChange={onOpenChange}
|
|
111
|
+
hasScrim={hasScrim}
|
|
93
112
|
label="Notification frequency"
|
|
94
113
|
height={height}>
|
|
95
114
|
<Section padding={4}>
|
|
@@ -120,13 +139,15 @@ function NotificationFrequencySheet({
|
|
|
120
139
|
);
|
|
121
140
|
}
|
|
122
141
|
|
|
123
|
-
interface NotificationChannelsSheetProps {
|
|
124
|
-
height: NotificationSheetHeight;
|
|
142
|
+
interface NotificationChannelsSheetProps extends StepSheetProps {
|
|
125
143
|
onBack: () => void;
|
|
126
144
|
onFinish: () => void;
|
|
127
145
|
}
|
|
128
146
|
|
|
129
147
|
function NotificationChannelsSheet({
|
|
148
|
+
isOpen,
|
|
149
|
+
onOpenChange,
|
|
150
|
+
hasScrim,
|
|
130
151
|
height,
|
|
131
152
|
onBack,
|
|
132
153
|
onFinish,
|
|
@@ -137,7 +158,9 @@ function NotificationChannelsSheet({
|
|
|
137
158
|
|
|
138
159
|
return (
|
|
139
160
|
<BottomSheet
|
|
140
|
-
|
|
161
|
+
isOpen={isOpen}
|
|
162
|
+
onOpenChange={onOpenChange}
|
|
163
|
+
hasScrim={hasScrim}
|
|
141
164
|
label="Notification channels"
|
|
142
165
|
height={height}>
|
|
143
166
|
<Section padding={4}>
|
|
@@ -175,47 +198,55 @@ function NotificationChannelsSheet({
|
|
|
175
198
|
);
|
|
176
199
|
}
|
|
177
200
|
|
|
178
|
-
|
|
201
|
+
type Step = 'overview' | 'frequency' | 'channels' | null;
|
|
202
|
+
|
|
203
|
+
interface MultiStepExampleProps {
|
|
179
204
|
height: NotificationSheetHeight;
|
|
180
205
|
hasScrim?: boolean;
|
|
181
206
|
}
|
|
182
207
|
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
208
|
+
function MultiStepExample({height, hasScrim = true}: MultiStepExampleProps) {
|
|
209
|
+
// One state value names the open step. Moving on closes one sheet and
|
|
210
|
+
// opens the next in the same update, which replaces it in place.
|
|
211
|
+
const [step, setStep] = useState<Step>(null);
|
|
212
|
+
const stepProps = (id: Step) => ({
|
|
213
|
+
isOpen: step === id,
|
|
214
|
+
onOpenChange: (isOpen: boolean) => {
|
|
215
|
+
// Clear the step only if it is still the open one: a step that closes
|
|
216
|
+
// because the person moved on must not undo the move.
|
|
217
|
+
if (!isOpen) {
|
|
218
|
+
setStep(current => (current === id ? null : current));
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
hasScrim,
|
|
222
|
+
height,
|
|
223
|
+
});
|
|
188
224
|
|
|
189
225
|
return (
|
|
190
226
|
<>
|
|
191
227
|
<Button
|
|
192
228
|
label="Set up notifications"
|
|
193
|
-
onClick={() =>
|
|
229
|
+
onClick={() => setStep('overview')}
|
|
230
|
+
/>
|
|
231
|
+
<NotificationOverviewSheet
|
|
232
|
+
{...stepProps('overview')}
|
|
233
|
+
onCancel={() => setStep(null)}
|
|
234
|
+
onContinue={() => setStep('frequency')}
|
|
235
|
+
/>
|
|
236
|
+
<NotificationFrequencySheet
|
|
237
|
+
{...stepProps('frequency')}
|
|
238
|
+
onBack={() => setStep('overview')}
|
|
239
|
+
onContinue={() => setStep('channels')}
|
|
240
|
+
/>
|
|
241
|
+
<NotificationChannelsSheet
|
|
242
|
+
{...stepProps('channels')}
|
|
243
|
+
onBack={() => setStep('frequency')}
|
|
244
|
+
onFinish={() => setStep(null)}
|
|
194
245
|
/>
|
|
195
|
-
<BottomSheetSwitcher
|
|
196
|
-
activeSheet={activeSheet}
|
|
197
|
-
onActiveSheetChange={setActiveSheet}
|
|
198
|
-
hasScrim={hasScrim}>
|
|
199
|
-
<NotificationOverviewSheet
|
|
200
|
-
height={height}
|
|
201
|
-
onCancel={() => setActiveSheet(null)}
|
|
202
|
-
onContinue={() => setActiveSheet('frequency')}
|
|
203
|
-
/>
|
|
204
|
-
<NotificationFrequencySheet
|
|
205
|
-
height={height}
|
|
206
|
-
onBack={() => setActiveSheet('overview')}
|
|
207
|
-
onContinue={() => setActiveSheet('channels')}
|
|
208
|
-
/>
|
|
209
|
-
<NotificationChannelsSheet
|
|
210
|
-
height={height}
|
|
211
|
-
onBack={() => setActiveSheet('frequency')}
|
|
212
|
-
onFinish={() => setActiveSheet(null)}
|
|
213
|
-
/>
|
|
214
|
-
</BottomSheetSwitcher>
|
|
215
246
|
</>
|
|
216
247
|
);
|
|
217
248
|
}
|
|
218
249
|
|
|
219
250
|
export default function BottomSheetSwitcherShowcase() {
|
|
220
|
-
return <
|
|
251
|
+
return <MultiStepExample height="hug" />;
|
|
221
252
|
}
|
|
@@ -6,7 +6,7 @@ export const doc = {
|
|
|
6
6
|
exampleFor: 'Thumbnail',
|
|
7
7
|
name: 'Thumbnail — Disabled',
|
|
8
8
|
displayName: 'Thumbnail — Disabled',
|
|
9
|
-
description: 'Thumbnails in the disabled state with reduced opacity. The remove
|
|
9
|
+
description: 'Thumbnails in the disabled state with reduced opacity. The open and remove buttons stay focusable and announced as disabled, and call nothing.',
|
|
10
10
|
isReady: true,
|
|
11
11
|
aspectRatio: 16 / 9,
|
|
12
12
|
componentsUsed: ['Thumbnail', 'Layout', 'Text'],
|
|
@@ -6,16 +6,23 @@ import {useState} from 'react';
|
|
|
6
6
|
import {Tokenizer} from '@astryxdesign/core/Tokenizer';
|
|
7
7
|
import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';
|
|
8
8
|
|
|
9
|
+
const tags: SearchableItem[] = [
|
|
10
|
+
{id: '1', label: 'Design'},
|
|
11
|
+
{id: '2', label: 'Engineering'},
|
|
12
|
+
{id: '3', label: 'Marketing'},
|
|
13
|
+
{id: '4', label: 'Product'},
|
|
14
|
+
{id: '5', label: 'Research'},
|
|
15
|
+
{id: '6', label: 'Sales'},
|
|
16
|
+
];
|
|
17
|
+
|
|
9
18
|
const source: SearchSource = {
|
|
10
|
-
search: () =>
|
|
11
|
-
|
|
19
|
+
search: (query: string) =>
|
|
20
|
+
tags.filter(tag => tag.label.toLowerCase().includes(query.toLowerCase())),
|
|
21
|
+
bootstrap: () => tags,
|
|
12
22
|
};
|
|
13
23
|
|
|
14
24
|
export default function TokenizerShowcase() {
|
|
15
|
-
const [value, setValue] = useState<SearchableItem[]>([
|
|
16
|
-
{id: '1', label: 'Design'},
|
|
17
|
-
{id: '2', label: 'Engineering'},
|
|
18
|
-
]);
|
|
25
|
+
const [value, setValue] = useState<SearchableItem[]>([tags[0], tags[1]]);
|
|
19
26
|
return (
|
|
20
27
|
<div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 400px)'}}>
|
|
21
28
|
<Tokenizer
|
package/assets/theme.template.ts
CHANGED
|
@@ -91,9 +91,11 @@ export const myTheme = defineTheme({
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Start from another theme instead of the defaults. Tokens are copied then
|
|
94
|
-
* overridden, `components` deep-merge, `icons` shallow-merge — but the
|
|
95
|
-
* configs below REPLACE the base's rather
|
|
96
|
-
* inputs to a generator, not values.
|
|
94
|
+
* overridden, `components` deep-merge, `icons` shallow-merge — but the
|
|
95
|
+
* typography, radius and color scale configs below REPLACE the base's rather
|
|
96
|
+
* than merging, because they are inputs to a generator, not values. `motion`
|
|
97
|
+
* inherits field by field: `fast`, `medium` and `ratio` regenerate the fast
|
|
98
|
+
* and medium durations, and a `slow` or `easing` left unset keeps the base's.
|
|
97
99
|
*
|
|
98
100
|
* Reference: `astryx theme list` (themes you can install and extend).
|
|
99
101
|
*/
|
|
@@ -312,10 +314,21 @@ export const myTheme = defineTheme({
|
|
|
312
314
|
|
|
313
315
|
/**
|
|
314
316
|
* Swap the artwork behind semantic icon names — every component that asks
|
|
315
|
-
* for `check`, `close`, `chevron-down` gets yours.
|
|
317
|
+
* for `check`, `close`, `chevron-down` gets yours. An entry may also be a
|
|
318
|
+
* pure function of `{size, variant}` that picks artwork for the size Icon
|
|
319
|
+
* renders at.
|
|
316
320
|
* Reference: `astryx docs icons` lists the names.
|
|
317
321
|
*/
|
|
318
|
-
// icons: {check: <MyCheck />,
|
|
322
|
+
// icons: {check: <MyCheck />, info: ({size}) => <MyInfo bold={size === 'sm'} />},
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The icon variant names this theme supports, listed once for the whole
|
|
326
|
+
* theme. An icon entry function receives `variant` typed as these names.
|
|
327
|
+
* A theme that sets the list replaces the one it would inherit; omit it to
|
|
328
|
+
* inherit the base's list.
|
|
329
|
+
* Reference: `astryx docs icons`.
|
|
330
|
+
*/
|
|
331
|
+
// iconVariants: ['outline', 'filled'],
|
|
319
332
|
|
|
320
333
|
/**
|
|
321
334
|
* Replace the small components that DRAW control state — the checkbox box,
|