@dxos/react-ui 0.8.1 → 0.8.2-main.10c050d
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/chunk-5Y5JI6KC.mjs +4355 -0
- package/dist/lib/browser/chunk-5Y5JI6KC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +75 -2986
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +85 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/node/chunk-KMS7RFL7.cjs +4340 -0
- package/dist/lib/node/chunk-KMS7RFL7.cjs.map +7 -0
- package/dist/lib/node/index.cjs +71 -2946
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +114 -0
- package/dist/lib/node/testing/index.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-ANVE7WX5.mjs +4357 -0
- package/dist/lib/node-esm/chunk-ANVE7WX5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +74 -2986
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +86 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/components/Avatars/Avatar.d.ts +4 -4
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +3 -3
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +0 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +10 -44
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts +4 -6
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts +7 -6
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +1 -4
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +2 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/index.d.ts +2 -2
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +33 -159
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +8 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +15 -6
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +5 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +2 -2
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +92 -20
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +40 -17
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useIconHref.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeCollisionPadding.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +8 -0
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/index.d.ts +1 -1
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/{withVariants.d.ts → withSurfaceVariantsLayout.d.ts} +2 -3
- package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -15
- package/src/components/Avatars/Avatar.stories.tsx +27 -27
- package/src/components/Avatars/Avatar.tsx +24 -21
- package/src/components/Avatars/AvatarGroup.stories.tsx +4 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
- package/src/components/Buttons/Button.stories.tsx +20 -15
- package/src/components/Buttons/IconButton.stories.tsx +9 -10
- package/src/components/Buttons/IconButton.tsx +9 -38
- package/src/components/Buttons/Toggle.stories.tsx +2 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +3 -7
- package/src/components/Clipboard/CopyButton.tsx +22 -24
- package/src/components/Dialogs/AlertDialog.stories.tsx +4 -11
- package/src/components/Dialogs/Dialog.stories.tsx +3 -3
- package/src/components/Dialogs/Dialog.tsx +8 -4
- package/src/components/Input/Input.stories.tsx +69 -58
- package/src/components/Input/Input.tsx +1 -0
- package/src/components/Lists/Tree.stories.tsx +2 -2
- package/src/components/Lists/Treegrid.stories.tsx +12 -12
- package/src/components/Main/Main.stories.tsx +2 -2
- package/src/components/Main/Main.tsx +1 -0
- package/src/components/Menus/ContextMenu.stories.tsx +2 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +2 -2
- package/src/components/Message/Message.stories.tsx +10 -4
- package/src/components/Popover/Popover.stories.tsx +2 -2
- package/src/components/Popover/Popover.tsx +8 -4
- package/src/components/ScrollArea/ScrollArea.stories.tsx +4 -4
- package/src/components/ScrollArea/ScrollArea.tsx +3 -0
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Toast/Toast.stories.tsx +15 -10
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +43 -18
- package/src/components/Tooltip/Tooltip.tsx +733 -58
- package/src/components/index.ts +1 -1
- package/src/playground/Controls.stories.tsx +4 -4
- package/src/playground/Custom.stories.tsx +137 -0
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/testing/decorators/index.ts +1 -1
- package/src/testing/decorators/withSurfaceVariantsLayout.tsx +53 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +0 -1
- package/src/testing/decorators/withVariants.tsx +0 -45
package/src/components/index.ts
CHANGED
|
@@ -8,12 +8,12 @@ export * from './Breadcrumb';
|
|
|
8
8
|
export * from './Buttons';
|
|
9
9
|
export * from './Clipboard';
|
|
10
10
|
export * from './Dialogs';
|
|
11
|
-
export * from './Menus';
|
|
12
11
|
export * from './Icon';
|
|
13
12
|
export * from './Input';
|
|
14
13
|
export * from './Link';
|
|
15
14
|
export * from './Lists';
|
|
16
15
|
export * from './Main';
|
|
16
|
+
export * from './Menus';
|
|
17
17
|
export * from './Message';
|
|
18
18
|
export * from './Popover';
|
|
19
19
|
export * from './Status';
|
|
@@ -8,7 +8,7 @@ import { FileTs, FileJs, ArrowClockwise, Bug, TextUnderline, TextB, TextItalic }
|
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { Input, Select, Toggle, Toolbar } from '../components';
|
|
11
|
-
import { withTheme,
|
|
11
|
+
import { withTheme, withSurfaceVariantsLayout } from '../testing';
|
|
12
12
|
|
|
13
13
|
const DefaultStory = () => {
|
|
14
14
|
const [checked, setChecked] = useState<boolean>(false);
|
|
@@ -81,11 +81,11 @@ const DefaultStory = () => {
|
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
export const Default = {};
|
|
85
|
-
|
|
86
84
|
export default {
|
|
87
85
|
title: 'ui/react-ui-core/Playground/Controls',
|
|
88
86
|
render: DefaultStory,
|
|
89
|
-
decorators: [
|
|
87
|
+
decorators: [withSurfaceVariantsLayout(), withTheme],
|
|
90
88
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
91
89
|
};
|
|
90
|
+
|
|
91
|
+
export const Default = {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { Button, IconButton, type ButtonProps, Tooltip } from '../components';
|
|
11
|
+
import { withTheme } from '../testing';
|
|
12
|
+
|
|
13
|
+
// TODO(burdon): Change density to 3 or 4 sizes: (large, medium, small; or 22, 28, 32, 40)
|
|
14
|
+
// TODO(burdon): IconButton should be square if no text.
|
|
15
|
+
// TODO(burdon): IconButton icon should be auto-sized based on density.
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Remove custom padding from all Buttons.
|
|
18
|
+
|
|
19
|
+
// TODO(burdon): Forms w/ labels.
|
|
20
|
+
// TODO(burdon): Card preview with sections.
|
|
21
|
+
|
|
22
|
+
const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
23
|
+
return (
|
|
24
|
+
<Tooltip.Provider>
|
|
25
|
+
<div className='flex flex-col gap-6'>
|
|
26
|
+
{/* Large */}
|
|
27
|
+
<div className='grid grid-cols-3 gap-4'>
|
|
28
|
+
<div className='flex justify-center'>
|
|
29
|
+
<Button {...args} density='coarse'>
|
|
30
|
+
{children}
|
|
31
|
+
</Button>
|
|
32
|
+
</div>
|
|
33
|
+
<div className='flex justify-center'>
|
|
34
|
+
<IconButton {...args} label='Test' icon='ph--atom--regular' size={7} density='coarse' />
|
|
35
|
+
</div>
|
|
36
|
+
<div className='flex justify-center'>
|
|
37
|
+
<IconButton
|
|
38
|
+
{...args}
|
|
39
|
+
label='Test'
|
|
40
|
+
icon='ph--atom--regular'
|
|
41
|
+
iconOnly
|
|
42
|
+
size={7}
|
|
43
|
+
density='coarse'
|
|
44
|
+
classNames='px-1.5'
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
{/* Medium */}
|
|
50
|
+
<div className='grid grid-cols-3 gap-4'>
|
|
51
|
+
<div className='flex justify-center'>
|
|
52
|
+
<Button {...args} density='fine'>
|
|
53
|
+
{children}
|
|
54
|
+
</Button>
|
|
55
|
+
</div>
|
|
56
|
+
<div className='flex justify-center'>
|
|
57
|
+
<IconButton {...args} label='Test' icon='ph--atom--regular' size={5} density='fine' classNames='px-2' />
|
|
58
|
+
</div>
|
|
59
|
+
<div className='flex justify-center'>
|
|
60
|
+
<IconButton
|
|
61
|
+
{...args}
|
|
62
|
+
label='Test'
|
|
63
|
+
icon='ph--atom--regular'
|
|
64
|
+
iconOnly
|
|
65
|
+
size={5}
|
|
66
|
+
density='fine'
|
|
67
|
+
classNames='py-1 px-1.5'
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
{/* Small */}
|
|
73
|
+
<div className='grid grid-cols-3 gap-4'>
|
|
74
|
+
<div className='flex justify-center'>
|
|
75
|
+
<Button {...args} density='fine' classNames={'!h-[24px] !text-[14px] p-0 px-1.5 min-bs-0'}>
|
|
76
|
+
{children}
|
|
77
|
+
</Button>
|
|
78
|
+
</div>
|
|
79
|
+
<div className='flex justify-center'>
|
|
80
|
+
<IconButton
|
|
81
|
+
{...args}
|
|
82
|
+
label='Test'
|
|
83
|
+
icon='ph--atom--regular'
|
|
84
|
+
density='fine'
|
|
85
|
+
size={4}
|
|
86
|
+
classNames={'!h-[24px] !text-[14px] p-1 min-bs-0 gap-0.5'}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
<div className='flex justify-center'>
|
|
90
|
+
<IconButton
|
|
91
|
+
{...args}
|
|
92
|
+
label='Test'
|
|
93
|
+
icon='ph--atom--regular'
|
|
94
|
+
iconOnly
|
|
95
|
+
density='fine'
|
|
96
|
+
size={4}
|
|
97
|
+
classNames={'!h-[24px] !text-[14px] p-1 min-bs-0'}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* TODO(burdon): Full variant with max width. */}
|
|
103
|
+
<div className='flex justify-center'>
|
|
104
|
+
<Button classNames='w-full max-w-[15rem] rounded' variant='default'>
|
|
105
|
+
Test
|
|
106
|
+
</Button>
|
|
107
|
+
</div>
|
|
108
|
+
<div className='flex justify-center'>
|
|
109
|
+
{/* TODO(burdon): Option to have button on RHS. Default size for icon should be 5 for this (medium) density. */}
|
|
110
|
+
<IconButton
|
|
111
|
+
classNames='w-full max-w-[15rem] rounded'
|
|
112
|
+
variant='primary'
|
|
113
|
+
icon='ph--arrows-clockwise--regular'
|
|
114
|
+
label='Test'
|
|
115
|
+
size={5}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</Tooltip.Provider>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const meta: Meta<typeof Button> = {
|
|
124
|
+
title: 'ui/react-ui-core/Playground/Custom',
|
|
125
|
+
component: Button,
|
|
126
|
+
render: DefaultStory,
|
|
127
|
+
decorators: [withTheme],
|
|
128
|
+
parameters: { layout: 'centered' },
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default meta;
|
|
132
|
+
|
|
133
|
+
type Story = StoryObj<typeof meta>;
|
|
134
|
+
|
|
135
|
+
export const Default: Story = {
|
|
136
|
+
args: { children: 'Test' },
|
|
137
|
+
};
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { withTheme } from '../testing';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const DefaultStory = () => {
|
|
12
12
|
return (
|
|
13
13
|
<div className='mli-auto p-8 max-is-[60rem] space-b-4'>
|
|
14
14
|
<h1 className='text-4xl font-medium'>
|
|
@@ -45,7 +45,7 @@ const TypographyStory = () => {
|
|
|
45
45
|
|
|
46
46
|
export default {
|
|
47
47
|
title: 'ui/react-ui-core/Playground/Typography',
|
|
48
|
-
render:
|
|
48
|
+
render: DefaultStory,
|
|
49
49
|
decorators: [withTheme],
|
|
50
50
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
51
51
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Decorator } from '@storybook/react';
|
|
6
|
+
import React, { type ComponentType, type PropsWithChildren } from 'react';
|
|
7
|
+
|
|
8
|
+
import { mx, surfaceShadow } from '@dxos/react-ui-theme';
|
|
9
|
+
import { type Density, type Elevation } from '@dxos/react-ui-types';
|
|
10
|
+
|
|
11
|
+
type Config = {
|
|
12
|
+
elevations?: { elevation: Elevation; surface?: string }[];
|
|
13
|
+
densities?: Density[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Container = ({ children, elevation, surface }: PropsWithChildren<{ elevation: Elevation; surface?: string }>) => (
|
|
17
|
+
<div className={mx('p-4 mlb-4 rounded-md border border-separator', surface, surfaceShadow({ elevation }))}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const Panel = ({
|
|
23
|
+
Story,
|
|
24
|
+
elevations,
|
|
25
|
+
densities,
|
|
26
|
+
className,
|
|
27
|
+
}: { Story: ComponentType } & Config & { className?: string }) => (
|
|
28
|
+
<div className={mx('flex flex-col h-full p-4', className)}>
|
|
29
|
+
{elevations?.map(({ elevation, surface }) =>
|
|
30
|
+
densities?.map((density) => (
|
|
31
|
+
<Container key={`${elevation}--${density}`} surface={surface} elevation={elevation}>
|
|
32
|
+
<Story />
|
|
33
|
+
</Container>
|
|
34
|
+
)),
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const withSurfaceVariantsLayout = ({
|
|
40
|
+
elevations = [
|
|
41
|
+
{ elevation: 'base', surface: 'bg-baseSurface' },
|
|
42
|
+
{ elevation: 'positioned', surface: 'bg-cardSurface' },
|
|
43
|
+
{ elevation: 'dialog', surface: 'bg-modalSurface' },
|
|
44
|
+
],
|
|
45
|
+
densities = ['coarse'],
|
|
46
|
+
}: Config = {}): Decorator => {
|
|
47
|
+
return (Story) => (
|
|
48
|
+
<div className='fixed inset-0 grid grid-cols-2 overflow-y-auto'>
|
|
49
|
+
<Panel Story={Story} className='light' elevations={elevations} densities={densities} />
|
|
50
|
+
<Panel Story={Story} className='dark' elevations={elevations} densities={densities} />
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withVariants.d.ts","sourceRoot":"","sources":["../../../../../src/testing/decorators/withVariants.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIpE,KAAK,MAAM,GAAG;IACZ,UAAU,CAAC,EAAE;QAAE,SAAS,EAAE,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1D,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,YAAY,gCAOtB,MAAM,KAAQ,SAkBhB,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
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, surfaceShadow } 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: 'positioned', surface: groupSurface },
|
|
24
|
-
{ elevation: 'dialog', 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, surfaceShadow({ elevation }))}>
|
|
36
|
-
<Story />
|
|
37
|
-
</div>
|
|
38
|
-
</DensityProvider>
|
|
39
|
-
))}
|
|
40
|
-
</div>
|
|
41
|
-
</ElevationProvider>
|
|
42
|
-
))}
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|