@dxos/react-ui 0.6.13 → 0.6.14-main.1366248
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/dist/lib/browser/index.mjs +740 -200
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +2932 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node-esm/index.mjs +2931 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +15 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +6 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +9 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.d.ts +1 -1
- package/dist/types/src/components/Buttons/Button.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +12 -17
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts +2 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +20 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +12 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +11 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +16 -1
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/List.stories.d.ts +2 -3
- package/dist/types/src/components/Lists/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts +5 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +3 -2
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +5 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts +105 -44
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +6 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +87 -21
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +20 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +20 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts +4 -2
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +10 -11
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +0 -3
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +4 -5
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +20 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +4 -2
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +30 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +13 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useThemeContext.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +2 -6
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Surfaces.stories.d.ts +6 -2
- package/dist/types/src/playground/Surfaces.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +1 -1
- package/dist/types/src/testing/decorators/index.d.ts +1 -0
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withVariants.d.ts +13 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -0
- package/package.json +28 -17
- package/src/components/Avatars/Avatar.stories.tsx +3 -2
- package/src/components/Avatars/AvatarGroup.stories.tsx +3 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +3 -2
- package/src/components/Buttons/Button.stories.tsx +34 -63
- package/src/components/Buttons/Button.tsx +46 -36
- package/src/components/Buttons/Toggle.stories.tsx +3 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +3 -2
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/Dialogs/AlertDialog.stories.tsx +3 -2
- package/src/components/Dialogs/Dialog.stories.tsx +3 -2
- package/src/components/Icon/Icon.tsx +11 -9
- package/src/components/Input/Input.stories.tsx +4 -3
- package/src/components/Link/Link.stories.tsx +1 -1
- package/src/components/Lists/List.stories.tsx +4 -4
- package/src/components/Lists/Tree.stories.tsx +3 -2
- package/src/components/Lists/Treegrid.stories.tsx +7 -5
- package/src/components/Main/Main.stories.tsx +3 -2
- package/src/components/Menus/ContextMenu.stories.tsx +3 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +43 -3
- package/src/components/Menus/DropdownMenu.tsx +518 -69
- package/src/components/Message/Message.stories.tsx +3 -2
- package/src/components/Popover/Popover.stories.tsx +27 -3
- package/src/components/Popover/Popover.tsx +524 -55
- package/src/components/ScrollArea/ScrollArea.stories.tsx +3 -2
- package/src/components/Select/Select.stories.tsx +14 -31
- package/src/components/Select/Select.tsx +24 -12
- package/src/components/Status/Status.stories.tsx +1 -2
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +17 -18
- package/src/components/Toast/Toast.stories.tsx +3 -2
- package/src/components/Toast/Toast.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +3 -2
- package/src/components/Toolbar/Toolbar.tsx +21 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +3 -2
- package/src/hooks/useThemeContext.ts +3 -1
- package/src/playground/Controls.stories.tsx +7 -10
- package/src/playground/Surfaces.stories.tsx +4 -3
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/testing/decorators/index.ts +1 -0
- package/src/testing/decorators/withVariants.tsx +45 -0
- package/dist/types/src/playground/helpers.d.ts +0 -6
- package/dist/types/src/playground/helpers.d.ts.map +0 -1
- package/src/playground/helpers.tsx +0 -32
|
@@ -34,8 +34,9 @@ const StorybookScrollArea = ({ children }: PropsWithChildren<{}>) => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export default {
|
|
37
|
-
title: 'react-ui/Scroll area',
|
|
38
|
-
component:
|
|
37
|
+
title: 'ui/react-ui-core/Scroll area',
|
|
38
|
+
component: ScrollArea,
|
|
39
|
+
render: StorybookScrollArea,
|
|
39
40
|
decorators: [withTheme],
|
|
40
41
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
41
42
|
};
|
|
@@ -4,38 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import { type StoryObj } from '@storybook/react';
|
|
8
|
+
import React, { useState } from 'react';
|
|
8
9
|
|
|
9
10
|
import { faker } from '@dxos/random';
|
|
10
|
-
import { type Density } from '@dxos/react-ui-types';
|
|
11
11
|
|
|
12
12
|
import { Select } from './Select';
|
|
13
|
-
import { withTheme } from '../../testing';
|
|
14
|
-
import { DensityProvider } from '../DensityProvider';
|
|
13
|
+
import { withVariants, withTheme } from '../../testing';
|
|
15
14
|
|
|
16
15
|
faker.seed(1234);
|
|
17
16
|
|
|
18
|
-
// TODO(burdon): Factor out density test.
|
|
19
|
-
const createDensityTest =
|
|
20
|
-
(Component: FC<any>) =>
|
|
21
|
-
({ ...props }) => {
|
|
22
|
-
const densities: Density[] = ['coarse', 'fine'];
|
|
23
|
-
return (
|
|
24
|
-
<div className='grid grid-cols-2'>
|
|
25
|
-
{densities.map((density) => (
|
|
26
|
-
<div key={density}>
|
|
27
|
-
<DensityProvider density={density}>
|
|
28
|
-
<Component {...props} />
|
|
29
|
-
</DensityProvider>
|
|
30
|
-
</div>
|
|
31
|
-
))}
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
17
|
type ItemProps = { id: string; text: string };
|
|
37
18
|
|
|
38
|
-
|
|
19
|
+
type StoryProps = { items: ItemProps[] };
|
|
20
|
+
|
|
21
|
+
const DefaultStory = ({ items = [] }: StoryProps) => {
|
|
39
22
|
const [value, setValue] = useState<string>();
|
|
40
23
|
return (
|
|
41
24
|
<Select.Root value={value} onValueChange={setValue}>
|
|
@@ -58,15 +41,15 @@ const StorybookSelect = ({ items = [] }: PropsWithChildren<{ items: ItemProps[]
|
|
|
58
41
|
);
|
|
59
42
|
};
|
|
60
43
|
|
|
61
|
-
export
|
|
62
|
-
title: 'react-ui/Select',
|
|
63
|
-
component: createDensityTest(StorybookSelect),
|
|
64
|
-
decorators: [withTheme],
|
|
65
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const Default = {
|
|
44
|
+
export const Default: StoryObj<StoryProps> = {
|
|
69
45
|
args: {
|
|
70
46
|
items: Array.from({ length: 16 }).map((_, i) => ({ id: `item-${i}`, text: faker.lorem.word() })),
|
|
71
47
|
},
|
|
72
48
|
};
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
title: 'ui/react-ui-core/Select',
|
|
52
|
+
render: DefaultStory,
|
|
53
|
+
decorators: [withVariants(), withTheme],
|
|
54
|
+
parameters: { chromatic: { disableSnapshot: false } },
|
|
55
|
+
};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { CaretDown, CaretUp
|
|
5
|
+
import { CaretDown, CaretUp } from '@phosphor-icons/react';
|
|
6
6
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
7
7
|
import React, { forwardRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import { useThemeContext } from '../../hooks';
|
|
10
10
|
import { type ThemedClassName } from '../../util';
|
|
11
11
|
import { Button, type ButtonProps } from '../Buttons';
|
|
12
|
+
import { Icon } from '../Icon';
|
|
12
13
|
|
|
13
14
|
type SelectRootProps = SelectPrimitive.SelectProps;
|
|
14
15
|
|
|
@@ -39,11 +40,9 @@ const SelectTriggerButton = forwardRef<HTMLButtonElement, SelectTriggerButtonPro
|
|
|
39
40
|
<SelectPrimitive.Trigger asChild ref={forwardedRef}>
|
|
40
41
|
<Button {...props}>
|
|
41
42
|
<SelectPrimitive.Value placeholder={placeholder}>{children}</SelectPrimitive.Value>
|
|
43
|
+
<span className='w-1 flex-1' />
|
|
42
44
|
<SelectPrimitive.Icon asChild>
|
|
43
|
-
|
|
44
|
-
<span className='w-1' />
|
|
45
|
-
<CaretDown className={tx('select.triggerIcon', 'select__trigger__icon', {})} weight='bold' />
|
|
46
|
-
</>
|
|
45
|
+
<CaretDown className={tx('select.triggerIcon', 'select__trigger__icon', {})} weight='bold' />
|
|
47
46
|
</SelectPrimitive.Icon>
|
|
48
47
|
</Button>
|
|
49
48
|
</SelectPrimitive.Trigger>
|
|
@@ -60,6 +59,7 @@ const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
|
|
|
60
59
|
<SelectPrimitive.Content
|
|
61
60
|
{...props}
|
|
62
61
|
className={tx('select.content', 'select__content', {}, classNames)}
|
|
62
|
+
position='popper'
|
|
63
63
|
ref={forwardedRef}
|
|
64
64
|
>
|
|
65
65
|
{children}
|
|
@@ -102,9 +102,22 @@ const SelectScrollDownButton = forwardRef<HTMLDivElement, SelectScrollDownButton
|
|
|
102
102
|
},
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
-
type SelectViewportProps = SelectPrimitive.SelectViewportProps
|
|
105
|
+
type SelectViewportProps = ThemedClassName<SelectPrimitive.SelectViewportProps>;
|
|
106
106
|
|
|
107
|
-
const SelectViewport =
|
|
107
|
+
const SelectViewport = forwardRef<HTMLDivElement, SelectViewportProps>(
|
|
108
|
+
({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
109
|
+
const { tx } = useThemeContext();
|
|
110
|
+
return (
|
|
111
|
+
<SelectPrimitive.SelectViewport
|
|
112
|
+
{...props}
|
|
113
|
+
className={tx('select.viewport', 'select__viewport', {}, classNames)}
|
|
114
|
+
ref={forwardedRef}
|
|
115
|
+
>
|
|
116
|
+
{children}
|
|
117
|
+
</SelectPrimitive.SelectViewport>
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
);
|
|
108
121
|
|
|
109
122
|
type SelectItemProps = ThemedClassName<SelectPrimitive.SelectItemProps>;
|
|
110
123
|
|
|
@@ -138,13 +151,13 @@ type SelectOptionProps = SelectItemProps;
|
|
|
138
151
|
|
|
139
152
|
const SelectOption = forwardRef<HTMLDivElement, SelectItemProps>(({ children, classNames, ...props }, forwardedRef) => {
|
|
140
153
|
const { tx } = useThemeContext();
|
|
141
|
-
|
|
142
154
|
return (
|
|
143
155
|
<SelectPrimitive.Item {...props} className={tx('select.item', 'option', {}, classNames)} ref={forwardedRef}>
|
|
144
156
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
<span className='grow w-1' />
|
|
158
|
+
{/* <SelectPrimitive.ItemIndicator className={tx('select.itemIndicator', 'option__indicator', {})}> */}
|
|
159
|
+
<Icon icon='ph--check--regular' />
|
|
160
|
+
{/* </SelectPrimitive.ItemIndicator> */}
|
|
148
161
|
</SelectPrimitive.Item>
|
|
149
162
|
);
|
|
150
163
|
});
|
|
@@ -174,7 +187,6 @@ type SelectArrowProps = ThemedClassName<SelectPrimitive.SelectArrowProps>;
|
|
|
174
187
|
|
|
175
188
|
const SelectArrow = forwardRef<SVGSVGElement, SelectArrowProps>(({ classNames, ...props }, forwardedRef) => {
|
|
176
189
|
const { tx } = useThemeContext();
|
|
177
|
-
|
|
178
190
|
return (
|
|
179
191
|
<SelectPrimitive.Arrow
|
|
180
192
|
{...props}
|
|
@@ -10,9 +10,8 @@ import { Status } from './Status';
|
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
|
-
title: 'react-ui/Status',
|
|
13
|
+
title: 'ui/react-ui-core/Status',
|
|
14
14
|
component: Status,
|
|
15
|
-
actions: { argTypesRegex: '^on.*' },
|
|
16
15
|
decorators: [withTheme],
|
|
17
16
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
18
17
|
};
|
|
@@ -14,33 +14,24 @@ import { ElevationProvider } from '../ElevationProvider';
|
|
|
14
14
|
|
|
15
15
|
export type ThemeMode = 'light' | 'dark';
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export type ThemeContextValue = {
|
|
18
18
|
tx: ThemeFunction<any>;
|
|
19
19
|
themeMode: ThemeMode;
|
|
20
20
|
hasIosKeyboard: boolean;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);
|
|
22
27
|
|
|
23
28
|
export type ThemeProviderProps = Omit<TranslationsProviderProps, 'children'> &
|
|
24
29
|
Partial<ThemeContextValue> &
|
|
25
30
|
PropsWithChildren<{
|
|
26
|
-
rootElevation?: Elevation;
|
|
27
31
|
rootDensity?: Density;
|
|
32
|
+
rootElevation?: Elevation;
|
|
28
33
|
}>;
|
|
29
34
|
|
|
30
|
-
export const ThemeContext = createContext<ThemeContextValue>({
|
|
31
|
-
tx: (_path, defaultClassName, _styleProps, ..._options) => defaultClassName,
|
|
32
|
-
themeMode: 'dark',
|
|
33
|
-
hasIosKeyboard: false,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const handleInputModalityChange = (isUsingKeyboard: boolean) => {
|
|
37
|
-
if (isUsingKeyboard) {
|
|
38
|
-
document.body.setAttribute('data-is-keyboard', 'true');
|
|
39
|
-
} else {
|
|
40
|
-
document.body.removeAttribute('data-is-keyboard');
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
35
|
export const ThemeProvider = ({
|
|
45
36
|
children,
|
|
46
37
|
fallback = null,
|
|
@@ -48,8 +39,8 @@ export const ThemeProvider = ({
|
|
|
48
39
|
appNs,
|
|
49
40
|
tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName,
|
|
50
41
|
themeMode = 'dark',
|
|
42
|
+
rootDensity = 'fine',
|
|
51
43
|
rootElevation = 'base',
|
|
52
|
-
rootDensity = 'coarse',
|
|
53
44
|
}: ThemeProviderProps) => {
|
|
54
45
|
useEffect(() => {
|
|
55
46
|
if (document.defaultView) {
|
|
@@ -75,3 +66,11 @@ export const ThemeProvider = ({
|
|
|
75
66
|
</ThemeContext.Provider>
|
|
76
67
|
);
|
|
77
68
|
};
|
|
69
|
+
|
|
70
|
+
const handleInputModalityChange = (isUsingKeyboard: boolean) => {
|
|
71
|
+
if (isUsingKeyboard) {
|
|
72
|
+
document.body.setAttribute('data-is-keyboard', 'true');
|
|
73
|
+
} else {
|
|
74
|
+
document.body.removeAttribute('data-is-keyboard');
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -45,8 +45,9 @@ const StorybookToast = (props: StorybookToastProps) => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export default {
|
|
48
|
-
title: 'react-ui/Toast',
|
|
49
|
-
component:
|
|
48
|
+
title: 'ui/react-ui-core/Toast',
|
|
49
|
+
component: Toast,
|
|
50
|
+
render: StorybookToast,
|
|
50
51
|
decorators: [withTheme],
|
|
51
52
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
52
53
|
};
|
|
@@ -24,7 +24,6 @@ import React, { type ComponentPropsWithRef, forwardRef, type FunctionComponent }
|
|
|
24
24
|
|
|
25
25
|
import { useThemeContext } from '../../hooks';
|
|
26
26
|
import { type ThemedClassName } from '../../util';
|
|
27
|
-
import { DensityProvider } from '../DensityProvider';
|
|
28
27
|
import { ElevationProvider } from '../ElevationProvider';
|
|
29
28
|
|
|
30
29
|
type ToastProviderProps = ToastProviderPrimitiveProps;
|
|
@@ -46,9 +45,7 @@ const ToastRoot = forwardRef<HTMLLIElement, ToastRootProps>(({ classNames, child
|
|
|
46
45
|
const { tx } = useThemeContext();
|
|
47
46
|
return (
|
|
48
47
|
<ToastRootPrimitive {...props} className={tx('toast.root', 'toast', {}, classNames)} ref={forwardedRef}>
|
|
49
|
-
<ElevationProvider elevation='chrome'>
|
|
50
|
-
<DensityProvider density='fine'>{children}</DensityProvider>
|
|
51
|
-
</ElevationProvider>
|
|
48
|
+
<ElevationProvider elevation='chrome'>{children}</ElevationProvider>
|
|
52
49
|
</ToastRootPrimitive>
|
|
53
50
|
);
|
|
54
51
|
});
|
|
@@ -70,8 +70,9 @@ const StorybookToolbar = (props: StorybookToolbarProps) => {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
export default {
|
|
73
|
-
title: 'react-ui/Toolbar',
|
|
74
|
-
component:
|
|
73
|
+
title: 'ui/react-ui-core/Toolbar',
|
|
74
|
+
component: Toolbar,
|
|
75
|
+
render: StorybookToolbar,
|
|
75
76
|
decorators: [withTheme],
|
|
76
77
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
77
78
|
};
|
|
@@ -7,7 +7,15 @@ import React, { forwardRef } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useThemeContext } from '../../hooks';
|
|
9
9
|
import { type ThemedClassName } from '../../util';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
ButtonGroup,
|
|
13
|
+
type ButtonGroupProps,
|
|
14
|
+
type ButtonProps,
|
|
15
|
+
Toggle,
|
|
16
|
+
type ToggleGroupItemProps,
|
|
17
|
+
type ToggleProps,
|
|
18
|
+
} from '../Buttons';
|
|
11
19
|
import { Link, type LinkProps } from '../Link';
|
|
12
20
|
import { Separator, type SeparatorProps } from '../Separator';
|
|
13
21
|
|
|
@@ -32,6 +40,16 @@ const ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>((props,
|
|
|
32
40
|
);
|
|
33
41
|
});
|
|
34
42
|
|
|
43
|
+
type ToolbarToggleProps = ToggleProps;
|
|
44
|
+
|
|
45
|
+
const ToolbarToggle = forwardRef<HTMLButtonElement, ToolbarToggleProps>((props, forwardedRef) => {
|
|
46
|
+
return (
|
|
47
|
+
<ToolbarPrimitive.Button asChild>
|
|
48
|
+
<Toggle {...props} ref={forwardedRef} />
|
|
49
|
+
</ToolbarPrimitive.Button>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
35
53
|
type ToolbarLinkProps = LinkProps;
|
|
36
54
|
|
|
37
55
|
const ToolbarLink = forwardRef<HTMLAnchorElement, ToolbarLinkProps>((props, forwardedRef) => {
|
|
@@ -84,6 +102,7 @@ export const Toolbar = {
|
|
|
84
102
|
Root: ToolbarRoot,
|
|
85
103
|
Button: ToolbarButton,
|
|
86
104
|
Link: ToolbarLink,
|
|
105
|
+
Toggle: ToolbarToggle,
|
|
87
106
|
ToggleGroup: ToolbarToggleGroup,
|
|
88
107
|
ToggleGroupItem: ToolbarToggleGroupItem,
|
|
89
108
|
Separator: ToolbarSeparator,
|
|
@@ -93,6 +112,7 @@ export type {
|
|
|
93
112
|
ToolbarRootProps,
|
|
94
113
|
ToolbarButtonProps,
|
|
95
114
|
ToolbarLinkProps,
|
|
115
|
+
ToolbarToggleProps,
|
|
96
116
|
ToolbarToggleGroupProps,
|
|
97
117
|
ToolbarToggleGroupItemProps,
|
|
98
118
|
ToolbarSeparatorProps,
|
|
@@ -29,8 +29,9 @@ const StoryTooltip = ({ content }: StoryTooltipProps) => (
|
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
export default {
|
|
32
|
-
title: 'react-ui/Tooltip',
|
|
33
|
-
component:
|
|
32
|
+
title: 'ui/react-ui-core/Tooltip',
|
|
33
|
+
component: Tooltip,
|
|
34
|
+
render: StoryTooltip,
|
|
34
35
|
decorators: [withTheme],
|
|
35
36
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
36
37
|
};
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { useContext } from 'react';
|
|
6
6
|
|
|
7
|
+
import { raise } from '@dxos/debug';
|
|
8
|
+
|
|
7
9
|
import { ThemeContext } from '../components';
|
|
8
10
|
|
|
9
|
-
export const useThemeContext = () => useContext(ThemeContext);
|
|
11
|
+
export const useThemeContext = () => useContext(ThemeContext) ?? raise(new Error('Missing ThemeContext'));
|
|
@@ -7,11 +7,10 @@ import '@dxos-theme';
|
|
|
7
7
|
import { FileTs, FileJs, ArrowClockwise, Bug, TextUnderline, TextB, TextItalic } from '@phosphor-icons/react';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { createScenarios } from './helpers';
|
|
11
10
|
import { Input, Select, Toggle, Toolbar } from '../components';
|
|
12
|
-
import { withTheme } from '../testing';
|
|
11
|
+
import { withTheme, withVariants } from '../testing';
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const DefaultStory = () => {
|
|
15
14
|
const [checked, setChecked] = useState<boolean>(false);
|
|
16
15
|
const [select, setSelect] = useState<string>();
|
|
17
16
|
|
|
@@ -82,13 +81,11 @@ const Story = () => {
|
|
|
82
81
|
);
|
|
83
82
|
};
|
|
84
83
|
|
|
84
|
+
export const Default = {};
|
|
85
|
+
|
|
85
86
|
export default {
|
|
86
|
-
title: 'react-ui/
|
|
87
|
-
|
|
88
|
-
decorators: [withTheme],
|
|
87
|
+
title: 'ui/react-ui-core/Playground/Controls',
|
|
88
|
+
render: DefaultStory,
|
|
89
|
+
decorators: [withVariants(), withTheme],
|
|
89
90
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
-
export const Default = {
|
|
93
|
-
render: createScenarios(Story),
|
|
94
|
-
};
|
|
@@ -47,7 +47,7 @@ const Surface = ({ children, level }: PropsWithChildren & { level: SurfaceLevel
|
|
|
47
47
|
);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const SurfaceStory = () => {
|
|
51
51
|
return (
|
|
52
52
|
<div className='bg-cubes p-10 m-0'>
|
|
53
53
|
<Surface level='fixed' />
|
|
@@ -61,8 +61,9 @@ const SurfacesStory = () => {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export default {
|
|
64
|
-
title: 'react-ui/
|
|
65
|
-
component:
|
|
64
|
+
title: 'ui/react-ui-core/Playground/Surfaces',
|
|
65
|
+
component: Surface,
|
|
66
|
+
render: SurfaceStory,
|
|
66
67
|
decorators: [withTheme],
|
|
67
68
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
68
69
|
};
|
|
@@ -44,8 +44,8 @@ const TypographyStory = () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export default {
|
|
47
|
-
title: 'react-ui/
|
|
48
|
-
|
|
47
|
+
title: 'ui/react-ui-core/Playground/Typography',
|
|
48
|
+
render: TypographyStory,
|
|
49
49
|
decorators: [withTheme],
|
|
50
50
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
51
51
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Decorator } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { modalSurface, groupSurface, mx, surfaceElevation } from '@dxos/react-ui-theme';
|
|
11
|
+
import { type Density, type Elevation } from '@dxos/react-ui-types';
|
|
12
|
+
|
|
13
|
+
import { DensityProvider, ElevationProvider } from '../../components';
|
|
14
|
+
|
|
15
|
+
type Config = {
|
|
16
|
+
elevations?: { elevation: Elevation; surface?: string }[];
|
|
17
|
+
densities?: Density[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const withVariants = ({
|
|
21
|
+
elevations = [
|
|
22
|
+
{ elevation: 'base' },
|
|
23
|
+
{ elevation: 'group', surface: groupSurface },
|
|
24
|
+
{ elevation: 'chrome', surface: modalSurface },
|
|
25
|
+
],
|
|
26
|
+
densities = ['coarse', 'fine'],
|
|
27
|
+
}: Config = {}): Decorator => {
|
|
28
|
+
return (Story) => (
|
|
29
|
+
<div className='flex flex-col gap-8'>
|
|
30
|
+
{elevations.map(({ elevation, surface }) => (
|
|
31
|
+
<ElevationProvider key={elevation} elevation={elevation}>
|
|
32
|
+
<div className='flex flex-col gap-8'>
|
|
33
|
+
{densities.map((density) => (
|
|
34
|
+
<DensityProvider key={density} density={density}>
|
|
35
|
+
<div className={mx('p-4 rounded-lg', surface, surfaceElevation({ elevation }))}>
|
|
36
|
+
<Story />
|
|
37
|
+
</div>
|
|
38
|
+
</DensityProvider>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
</ElevationProvider>
|
|
42
|
+
))}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/playground/helpers.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOtD,eAAO,MAAM,eAAe,cACd,iBAAiB,CAAC,GAAG,CAAC;;uBAiBjC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import React, { type FunctionComponent } from 'react';
|
|
8
|
-
|
|
9
|
-
import { type Density } from '@dxos/react-ui-types';
|
|
10
|
-
|
|
11
|
-
import { DensityProvider, ElevationProvider } from '../components';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Grid: density, variant (context?), elevation.
|
|
14
|
-
export const createScenarios =
|
|
15
|
-
(Component: FunctionComponent<any>) =>
|
|
16
|
-
({ ...props }) => {
|
|
17
|
-
const densities: Density[] = ['coarse', 'fine'];
|
|
18
|
-
return (
|
|
19
|
-
<div className='flex flex-col space-y-8'>
|
|
20
|
-
{densities.map((density) => (
|
|
21
|
-
<div key={density}>
|
|
22
|
-
<ElevationProvider elevation='chrome'>
|
|
23
|
-
<DensityProvider density={density}>
|
|
24
|
-
<label className='p-2 text-xs'>{density}</label>
|
|
25
|
-
<Component {...props} />
|
|
26
|
-
</DensityProvider>
|
|
27
|
-
</ElevationProvider>
|
|
28
|
-
</div>
|
|
29
|
-
))}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|