Skip to content

Commit 6f5fdf7

Browse files
Michael AdlfingerMichael Adlfinger
authored andcommitted
fix: select options, default values
leverage inference of control types by args attribute
1 parent 32d7e2d commit 6f5fdf7

File tree

21 files changed

+79
-125
lines changed

21 files changed

+79
-125
lines changed

src/Alert/index.stories.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,18 @@ import { Alert, AlertProps } from './index';
55

66
export default {
77
title: 'Alert',
8+
args: {
9+
closable: false,
10+
showIcon: false,
11+
type: 'success',
12+
},
813
argTypes: {
914
onClose: { action: 'clicked' },
10-
closable: {
11-
control: {
12-
type: 'boolean',
13-
checked: false,
14-
},
15-
},
16-
showIcon: {
17-
control: {
18-
type: 'boolean',
19-
checked: false,
20-
},
21-
},
2215
type: {
2316
control: {
2417
type: 'inline-radio',
25-
options: ['success', 'info', 'warning', 'error'],
26-
default: 'success',
2718
},
19+
options: ['success', 'info', 'warning', 'error'],
2820
},
2921
},
3022
};

src/Avatar/index.stories.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { Avatar, AvatarProps, UserAvatar, UserAvatarProps } from './index';
1010

1111
export default {
1212
title: 'Avatar',
13+
args: {
14+
username: 'ABC',
15+
},
1316
};
1417

1518
export const Default: Story<AvatarProps> = function Default(args) {
@@ -31,16 +34,12 @@ export const CustomizableUserAvatar: Story<UserAvatarProps> =
3134
return <UserAvatar {...args} />;
3235
};
3336

34-
CustomizableUserAvatar.argTypes = {
35-
username: { control: { type: 'text' }, defaultValue: 'ABC' },
36-
};
37-
3837
export const VariableUserAvatars: Story<Omit<UserAvatarProps, 'username'>> =
3938
function VariableUserAvatars(args) {
4039
return (
4140
<>
4241
{range(1, 50).map((i) => (
43-
<UserAvatar key={i} username={randomString()} {...args} />
42+
<UserAvatar key={i} {...args} username={randomString()} />
4443
))}
4544
</>
4645
);

src/Button/index.stories.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,18 @@ import {
2020
export default {
2121
title: 'Button',
2222
component: Button,
23+
args: {
24+
loading: false,
25+
disabled: false,
26+
},
2327
argTypes: {
2428
color: { control: 'color' },
2529
onClick: { action: 'clicked' },
2630
size: {
2731
control: {
2832
type: 'select',
29-
options: ['small', 'medium', 'large'],
30-
},
31-
},
32-
loading: {
33-
control: {
34-
type: 'boolean',
35-
},
36-
},
37-
disabled: {
38-
control: {
39-
type: 'boolean',
4033
},
34+
options: ['small', 'medium', 'large'],
4135
},
4236
},
4337
};

src/Fields/index.stories.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import { formItemFieldProps } from './formItemFieldProps';
2424

2525
export default {
2626
title: 'Fields',
27+
args: {
28+
disabled: false,
29+
hasError: false,
30+
},
2731
};
2832

2933
type FormType = {
@@ -87,20 +91,6 @@ export const ControlledError: Story<{
8791
</FieldProvider>
8892
);
8993
};
90-
ControlledError.argTypes = {
91-
disabled: {
92-
control: {
93-
type: 'boolean',
94-
checked: false,
95-
},
96-
},
97-
hasError: {
98-
control: {
99-
type: 'boolean',
100-
checked: false,
101-
},
102-
},
103-
};
10494

10595
export const NestedProviders: Story<FieldProviderProps> =
10696
function NestedProviders(props) {
@@ -119,14 +109,6 @@ export const NestedProviders: Story<FieldProviderProps> =
119109
</FieldProvider>
120110
);
121111
};
122-
NestedProviders.argTypes = {
123-
disabled: {
124-
control: {
125-
type: 'boolean',
126-
checked: false,
127-
},
128-
},
129-
};
130112

131113
function AllFields() {
132114
const formMethods = useFormContext<FormType>();

src/Form/index.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { Form, FormProps } from './index';
88

99
export default {
1010
title: 'Form',
11+
args: {
12+
bordered: false,
13+
loading: false,
14+
},
1115
argTypes: {
12-
bordered: { control: 'boolean' },
13-
loading: { control: 'boolean' },
1416
onFinish: { action: 'clicked' },
1517
onFinishFailed: { action: 'clicked' },
1618
},

src/Image/index.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { Image, ImageProps } from './index';
66
export default {
77
title: 'Image',
88
component: Image,
9-
argTypes: { width: { control: { type: 'number' }, defaultValue: 200 } },
9+
args: {
10+
width: 200,
11+
},
1012
};
1113

1214
export const Default: Story<ImageProps> = function Default(args) {

src/ImageMap/index.stories.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { PopoverArea } from './PopoverArea';
1111

1212
export default {
1313
title: 'ImageMap',
14+
args: {
15+
src: 'https://picsum.photos/600/600',
16+
},
1417
};
1518

1619
export const TecanLayoutExample: Story = function Default() {
@@ -63,10 +66,3 @@ export const Default: Story<ImageMapProps> = function Default(args) {
6366
</ImageMap>
6467
);
6568
};
66-
67-
Default.argTypes = {
68-
src: {
69-
control: { type: 'text' },
70-
defaultValue: 'https://picsum.photos/600/600',
71-
},
72-
};

src/List/index.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { List, ListProps } from './index';
66
export default {
77
title: 'List',
88
component: List,
9-
argTypes: {
10-
bordered: { control: 'boolean' },
11-
loading: { control: 'boolean' },
9+
args: {
10+
bordered: false,
11+
loading: false,
1212
},
1313
};
1414

src/Modal/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { WithModal, WithModalProps } from './WithModal';
99

1010
export default {
1111
title: 'Modal',
12-
argTypes: {
13-
width: { control: 'number' },
12+
args: {
13+
width: 500,
1414
},
1515
};
1616

src/Plate/index.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { Plate } from './index';
1515

1616
export default {
1717
title: 'Plate',
18-
argTypes: {
19-
loading: { control: 'boolean' },
20-
isDraggable: { control: 'boolean' },
18+
args: {
19+
isDraggable: false,
20+
loading: false,
2121
},
2222
};
2323

0 commit comments

Comments
 (0)