-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathChoiceGroup.stories.tsx
113 lines (111 loc) · 3.05 KB
/
ChoiceGroup.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import * as React from 'react';
import Screener from 'screener-storybook/src/screener';
import { storiesOf } from '@storybook/react';
import { FabricDecorator } from '../utilities/index';
import { ChoiceGroup, IChoiceGroupOption } from '@fluentui/react';
import { TestImages } from '@fluentui/example-data';
const options: IChoiceGroupOption[] = [
{ key: 'A', text: 'Selected' },
{ key: 'B', text: 'Unselected' },
{ key: 'C', text: 'Disabled', disabled: true },
];
storiesOf('ChoiceGroup', module)
.addDecorator(FabricDecorator)
.addDecorator(story => (
<Screener
steps={new Screener.Steps()
.snapshot('default', { cropTo: '.testWrapper' })
.hover('div.ms-ChoiceField:nth-of-type(1)')
.snapshot('hover unselected', { cropTo: '.testWrapper' })
.click('div.ms-ChoiceField:nth-of-type(1)')
.snapshot('selected', { cropTo: '.testWrapper' })
.click('div.ms-ChoiceField:nth-of-type(1)')
.hover('div.ms-ChoiceField:nth-of-type(1)')
.snapshot('hover selected', { cropTo: '.testWrapper' })
.end()}
>
{story()}
</Screener>
))
.addStory('Root', () =>
// prettier-ignore
<ChoiceGroup
options={ options }
label="Pick one"
/>,
)
.addStory('Required', () =>
// prettier-ignore
<ChoiceGroup
options={ options }
label="Pick one"
required
/>,
)
.addStory(
'With icons',
() => (
<ChoiceGroup
label="Pick one icon"
options={[
{
key: 'day',
iconProps: { iconName: 'CalendarDay' },
text: 'Day',
},
{
key: 'week',
iconProps: { iconName: 'CalendarWeek' },
text: 'Week',
},
{
key: 'month',
iconProps: { iconName: 'Calendar' },
text: 'Month',
disabled: true,
},
]}
/>
),
{ rtl: true },
)
.addStory('With default size images', () => (
<ChoiceGroup
label="Pick one image"
options={[
{
key: 'bar',
imageSrc: TestImages.choiceGroupBarUnselected,
selectedImageSrc: TestImages.choiceGroupBarSelected,
text: 'Clustered bar chart',
},
{
key: 'pie',
imageSrc: TestImages.choiceGroupBarUnselected,
selectedImageSrc: TestImages.choiceGroupBarSelected,
text: 'Pie chart',
},
]}
/>
))
.addStory('With large size images', () => (
<ChoiceGroup
label="Pick one image"
options={[
{
key: 'bar2',
imageSrc: TestImages.choiceGroupBarUnselected,
selectedImageSrc: TestImages.choiceGroupBarSelected,
imageSize: { width: 120, height: 120 },
text: 'Clustered bar chart',
},
{
key: 'pie2',
imageSrc: TestImages.choiceGroupBarUnselected,
selectedImageSrc: TestImages.choiceGroupBarSelected,
imageSize: { width: 120, height: 120 },
text: 'Pie chart',
},
]}
/>
));