Skip to content

Commit 722c326

Browse files
authored
chore: RSP storybook updates (#8391)
* chore: TS explicit module boundaries RSP 1 * card * checkbox * Color * combobox, contextualhelp, datepicker * dialog * divider, dropzone, form, icon, illustratedmessage, image * fix lint * inlinealert, label, labeledvalue, layout * link, list, listbox * menu * meter, numberfield, overlays, picker * progress, provider, radio * searchfield, slider, steplist, story-utils, switch * table * tabs, text, textfield, toast, tooltip * finish last tab * tree, view, well * revert source file changes * categorise all RAC stories
1 parent 66d65a9 commit 722c326

File tree

205 files changed

+3243
-2642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+3243
-2642
lines changed

packages/@react-spectrum/accordion/chromatic-fc/Accordion.stories.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Meta} from '@storybook/react';
13+
import {Meta, StoryObj} from '@storybook/react';
14+
import React from 'react';
1415
import {SpectrumAccordionProps} from '../src/Accordion';
1516
import {Template} from '../chromatic/Accordion.stories';
1617

@@ -20,7 +21,9 @@ const meta: Meta<SpectrumAccordionProps> = {
2021

2122
export default meta;
2223

23-
export const Default = {
24-
render: Template,
24+
export type AccordionStory = StoryObj<SpectrumAccordionProps>;
25+
26+
export const Default: AccordionStory = {
27+
render: (args) => <Template {...args} />,
2528
args: {defaultExpandedKeys: ['shared']}
2629
};

packages/@react-spectrum/accordion/chromatic/Accordion.stories.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Accordion, Disclosure, DisclosurePanel, DisclosureTitle} from '../';
14-
import {Meta} from '@storybook/react';
15-
import React from 'react';
13+
import {Accordion, Disclosure, DisclosurePanel, DisclosureTitle, SpectrumAccordionProps} from '../';
14+
import {Meta, StoryObj} from '@storybook/react';
15+
import React, {JSX} from 'react';
1616

1717
const meta: Meta = {
1818
title: 'Accordion',
@@ -22,7 +22,9 @@ const meta: Meta = {
2222

2323
export default meta;
2424

25-
export const Template = (args) => (
25+
export type AccordionStory = StoryObj<SpectrumAccordionProps>;
26+
27+
export const Template = (args: SpectrumAccordionProps): JSX.Element => (
2628
<Accordion {...args}>
2729
<Disclosure id="files">
2830
<DisclosureTitle>
@@ -51,16 +53,16 @@ export const Template = (args) => (
5153
</Accordion>
5254
);
5355

54-
export const Default = {
55-
render: Template
56+
export const Default: AccordionStory = {
57+
render: (args) => <Template {...args} />
5658
};
5759

58-
export const WithExpandedKeys = {
59-
render: Template,
60+
export const WithExpandedKeys: AccordionStory = {
61+
render: (args) => <Template {...args} />,
6062
args: {defaultExpandedKeys: ['shared']}
6163
};
6264

63-
export const WithDisabledDisclosure = {
65+
export const WithDisabledDisclosure: AccordionStory = {
6466
render: (args) => (
6567
<Accordion {...args}>
6668
<Disclosure id="files">
@@ -90,22 +92,22 @@ export const WithDisabledDisclosure = {
9092
</Accordion>)
9193
};
9294

93-
export const Disabled = {
94-
render: Template,
95+
export const Disabled: AccordionStory = {
96+
render: (args) => <Template {...args} />,
9597
args: {isDisabled: true}
9698
};
9799

98-
export const Quiet = {
99-
render: Template,
100+
export const Quiet: AccordionStory = {
101+
render: (args) => <Template {...args} />,
100102
args: {isQuiet: true}
101103
};
102104

103-
export const WithWrappingTitle = {
105+
export const WithWrappingTitle: AccordionStory = {
104106
render: (args) => (
105107
<Accordion maxWidth="size-3000" {...args}>
106108
<Disclosure id="files">
107109
<DisclosureTitle>
108-
Long long long long long long long long long long long long long long long long wrapping title
110+
Long long long long long long long long long long long long long long long long wrapping title
109111
</DisclosureTitle>
110112
<DisclosurePanel>
111113
Files content

packages/@react-spectrum/accordion/chromatic/Disclosure.stories.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Disclosure, DisclosurePanel, DisclosureTitle} from '../';
14-
import {Meta} from '@storybook/react';
15-
import React from 'react';
13+
import {Disclosure, DisclosurePanel, DisclosureTitle, SpectrumDisclosureProps} from '../';
14+
import {Meta, StoryObj} from '@storybook/react';
15+
import React, {JSX} from 'react';
1616

1717
const meta: Meta = {
1818
title: 'Disclosure',
@@ -22,7 +22,9 @@ const meta: Meta = {
2222

2323
export default meta;
2424

25-
export const Template = (args) => (
25+
export type DisclosureStory = StoryObj<SpectrumDisclosureProps>;
26+
27+
export const Template = (args: SpectrumDisclosureProps): JSX.Element => (
2628
<Disclosure {...args}>
2729
<DisclosureTitle>
2830
Your files
@@ -33,27 +35,29 @@ export const Template = (args) => (
3335
</Disclosure>
3436
);
3537

36-
export const Default = {
37-
render: Template
38+
export const Default: DisclosureStory = {
39+
render: (args) => <Template {...args} />
3840
};
3941

40-
export const Disabled = {
41-
render: Template,
42+
export const Disabled: DisclosureStory = {
43+
render: (args) => <Template {...args} />,
4244
args: {isDisabled: true}
4345
};
4446

45-
export const Quiet = {
46-
render: Template,
47+
export const Quiet: DisclosureStory = {
48+
render: (args) => <Template {...args} />,
4749
args: {isQuiet: true}
4850
};
4951

50-
export const WrappingTitle = (args) => (
51-
<Disclosure maxWidth="size-3000" {...args}>
52-
<DisclosureTitle>
53-
Long long long long long long long long long long long long long long long long wrapping title
54-
</DisclosureTitle>
55-
<DisclosurePanel>
56-
Files content
57-
</DisclosurePanel>
58-
</Disclosure>
59-
);
52+
export const WrappingTitle: DisclosureStory = {
53+
render: (args) => (
54+
<Disclosure maxWidth="size-3000" {...args}>
55+
<DisclosureTitle>
56+
Long long long long long long long long long long long long long long long long wrapping title
57+
</DisclosureTitle>
58+
<DisclosurePanel>
59+
Files content
60+
</DisclosurePanel>
61+
</Disclosure>
62+
)
63+
};

packages/@react-spectrum/actionbar/chromatic-fc/ActionBar.stories.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@
1111
* governing permissions and limitations under the License.
1212
*/
1313

14-
import {Default, LargeWidth} from '../chromatic/ActionBar.stories';
14+
import {Example} from '../stories/Example';
1515
import {Flex} from '@react-spectrum/layout';
1616
import React from 'react';
17+
import {StoryFn} from '@storybook/react';
1718

1819
export default {
1920
title: 'ActionBar'
2021
};
2122

22-
export const All = () => (
23+
export type ActionBarStory = StoryFn<typeof Example>;
24+
25+
export const All: ActionBarStory = () => (
2326
<Flex gap="size-100" direction={'column'}>
2427
<h2>Default</h2>
25-
<Default />
28+
<Flex gap="size-250">
29+
<Example />
30+
<Example defaultSelectedKeys={new Set(['Foo 1'])} />
31+
</Flex>
2632
<h2>Large width</h2>
27-
<LargeWidth />
33+
<Example isEmphasized tableWidth={800} isQuiet defaultSelectedKeys={new Set(['Foo 1'])} />
2834
</Flex>
2935
);
3036
All.story = {

packages/@react-spectrum/actionbar/chromatic/ActionBar.stories.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
import {Example, Example2} from '../stories/Example';
1414
import {Flex} from '@react-spectrum/layout';
1515
import React from 'react';
16+
import {StoryFn} from '@storybook/react';
1617

1718
export default {
1819
title: 'ActionBar'
1920
};
2021

21-
export const Default = () => (
22+
export type ActionBarStory = StoryFn<typeof Example>;
23+
24+
export const Default: ActionBarStory = () => (
2225
<Flex gap="size-250">
2326
<Example />
2427
<Example defaultSelectedKeys={new Set(['Foo 1'])} />
@@ -29,28 +32,28 @@ Default.story = {
2932
name: 'default'
3033
};
3134

32-
export const IsEmphasized = () => <Example isEmphasized defaultSelectedKeys={new Set(['Foo 1'])} />;
35+
export const IsEmphasized: ActionBarStory = () => <Example isEmphasized defaultSelectedKeys={new Set(['Foo 1'])} />;
3336

3437
IsEmphasized.story = {
3538
name: 'isEmphasized'
3639
};
3740

38-
export const LargeWidth = () => (
41+
export const LargeWidth: ActionBarStory = () => (
3942
<Example isEmphasized tableWidth={800} isQuiet defaultSelectedKeys={new Set(['Foo 1'])} />
4043
);
4144

4245
LargeWidth.story = {
4346
name: 'large width'
4447
};
4548

46-
export const CollapsedIcons = () => (
49+
export const CollapsedIcons: ActionBarStory = () => (
4750
<Example isEmphasized tableWidth={500} isQuiet defaultSelectedKeys={new Set(['Foo 1'])} />
4851
);
4952

5053
CollapsedIcons.story = {
5154
name: 'collapsed icons'
5255
};
5356

54-
export const CollapseRounding = () => (
57+
export const CollapseRounding: ActionBarStory = () => (
5558
<Example2 tableWidth={800} defaultSelectedKeys={new Set(['Foo 1'])} />
5659
);

packages/@react-spectrum/actionbar/stories/Example.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Duplicate from '@spectrum-icons/workflow/Duplicate';
1919
import Edit from '@spectrum-icons/workflow/Edit';
2020
import {mergeProps} from '@react-aria/utils';
2121
import Move from '@spectrum-icons/workflow/Move';
22-
import React, {useRef, useState} from 'react';
22+
import React, {JSX, useRef, useState} from 'react';
2323
import {Selection} from '@react-types/shared';
2424
import {Text} from '@react-spectrum/text';
2525

@@ -48,7 +48,7 @@ let defaultItems = [
4848
{test: 'Test 2', foo: 'Foo 16', bar: 'Bar 2', yay: 'Yay 2', baz: 'Baz 2'}
4949
];
5050

51-
export function Example(props: any = {}) {
51+
export function Example(props: any = {}): JSX.Element {
5252
const [selectedKeys, setSelectedKeys] = useState<Selection>(props.defaultSelectedKeys || new Set());
5353
let [items, setItems] = useState(defaultItems);
5454

@@ -118,7 +118,7 @@ export function Example(props: any = {}) {
118118
);
119119
}
120120

121-
export function Example2(props: any = {}) {
121+
export function Example2(props: any = {}): JSX.Element {
122122
const [selectedKeys, setSelectedKeys] = useState<Selection>(props.defaultSelectedKeys || new Set());
123123
let [items, setItems] = useState(defaultItems);
124124

packages/@react-spectrum/actiongroup/chromatic-fc/ActionGroup.stories.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,41 @@
1111
*/
1212

1313

14-
import {Compact, Default, IsDisabled, IsEmphasized, IsQuiet, StaticColorBlack, StaticColorWhite} from '../chromatic/ActionGroup.stories';
14+
import {docItems, editItems, Render, viewItems} from '../chromatic/ActionGroup.stories';
1515
import {Flex} from '@react-spectrum/layout';
1616
import React from 'react';
17+
import {StoryFn} from '@storybook/react';
18+
import {View} from '@react-spectrum/view';
1719

1820
export default {
1921
title: 'ActionGroup'
2022
};
2123

22-
export const All = () => (
24+
export type ActionGroupStory = StoryFn<typeof Render>;
25+
26+
export const All: ActionGroupStory = () => (
2327
<Flex gap="size-100" direction={'column'}>
2428
<h2>default</h2>
25-
<Default />
29+
<Render items={docItems} />
2630
<h2>isDisabled</h2>
27-
<IsDisabled />
31+
<Render items={docItems} isDisabled defaultSelectedKeys={['1']} />
2832
<h2>compact</h2>
29-
<Compact />
33+
<Render items={viewItems} density="compact" defaultSelectedKeys={['1']} />
3034
<h2>isQuiet</h2>
31-
<IsQuiet />
35+
<Render items={editItems} isQuiet defaultSelectedKeys={['1']} />
3236
<h2>isEmphasized</h2>
33-
<IsEmphasized />
37+
<Render items={docItems} isEmphasized defaultSelectedKeys={['1']} />
3438
<h2>staticColor: black</h2>
35-
<StaticColorBlack />
39+
<View backgroundColor="static-yellow-400" padding="size-1000">
40+
<Render items={viewItems} staticColor="black" defaultSelectedKeys={['1']} />
41+
</View>
3642
<h2>staticColor: white</h2>
37-
<StaticColorWhite />
43+
<View backgroundColor="static-blue-700" padding="size-1000">
44+
<Render items={viewItems} staticColor="white" defaultSelectedKeys={['1']} />
45+
</View>
3846
</Flex>
3947
);
48+
4049
All.story = {
4150
name: 'all'
4251
};

0 commit comments

Comments
 (0)