-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathControlDropdown.stories.tsx
More file actions
83 lines (72 loc) · 2.11 KB
/
Copy pathControlDropdown.stories.tsx
File metadata and controls
83 lines (72 loc) · 2.11 KB
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
import { useRef } from 'react';
import { Meta, StoryFn } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import Paragraph from '../Paragraph/Paragraph';
import { Center } from '../layout';
import { ControlDropdownProps } from './ControlDropdown.types';
import ControlDropdown from './ControlDropdown';
export default {
title: 'components/ControlDropdown',
component: ControlDropdown,
parameters: {
docs: {
story: { inline: false, height: 300 },
},
},
} as Meta;
const ControlDropdownTemplate: StoryFn<ControlDropdownProps> = (args) => {
const handlerRef = useRef<HTMLSpanElement | null>(null);
return (
<Center maxWidth={150} areChildrenCentered>
<span ref={handlerRef}>
<button type="button">Dropdown handler</button>
<ControlDropdown {...args} parentRef={handlerRef}>
<Paragraph>Dropdown content</Paragraph>
</ControlDropdown>
</span>
</Center>
);
};
export const Playground = ControlDropdownTemplate.bind({});
Playground.args = {
isOpen: true,
title: 'Dropdown title',
onOpen: action('OnOpen'),
onClose: action('OnClose'),
onSubmit: action('OnSubmit'),
};
Playground.parameters = {
screenshot: { skip: true },
};
export const WithResetButton = ControlDropdownTemplate.bind({});
WithResetButton.args = {
...Playground.args,
onReset: action('OnReset'),
};
export const BottomLeftPlacement = ControlDropdownTemplate.bind({});
BottomLeftPlacement.args = {
...Playground.args,
placement: 'bottom-start',
};
export const BottomPlacement = ControlDropdownTemplate.bind({});
BottomPlacement.args = {
...Playground.args,
placement: 'bottom',
};
export const BottomRightPlacement = ControlDropdownTemplate.bind({});
BottomRightPlacement.args = {
...Playground.args,
placement: 'bottom-end',
};
export const WithCustomWidth = ControlDropdownTemplate.bind({});
WithCustomWidth.args = {
...BottomPlacement.args,
width: 500,
};
export const WithCustomLabels = ControlDropdownTemplate.bind({});
WithCustomLabels.args = {
...WithResetButton.args,
submitLabel: 'Send',
closeLabel: 'Cancel',
resetLabel: 'Wipe out',
};