-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathstorybook-stories.jsx
127 lines (116 loc) · 2.92 KB
/
storybook-stories.jsx
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* eslint-disable react/display-name, jsx-a11y/no-noninteractive-tabindex */
import React from 'react';
import { storiesOf } from '@storybook/react';
import IconSettings from '../../icon-settings';
import { POPOVER_TOOLTIP } from '../../../utilities/constants';
import Tooltip from '../../tooltip';
import AnchoredNubbin from '../__examples__/anchored-nubbin';
import Base from '../__examples__/base';
import ButtonGroupExample from '../__examples__/button-group';
import ButtonExample from '../__examples__/button';
import LearnMoreExample from '../__examples__/learn-more';
import WithDelay from '../__examples__/with-delay';
import Icon from '../../icon';
import Button from '../../button';
const getPopoverTooltip = (props) => (
<Tooltip {...props}>
<Button label="Trigger Tooltip" />
</Tooltip>
);
const getPopoverTooltipAlign = (props) => {
/* eslint-disable react/prop-types */
const children = [];
const align = [
'top',
'top left',
'top right',
'right',
'right top',
'right bottom',
'bottom',
'bottom left',
'bottom right',
'left',
'left top',
'left bottom',
];
align.forEach((value) => {
children.push(
<div
key={value}
data-ignore-axe-duplicate-id-aria
style={{ margin: '100px auto' }}
>
<Tooltip {...props} align={value}>
{props.trigger}
</Tooltip>
</div>
);
});
return <div key="container">{children}</div>;
};
const content =
'Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi.';
storiesOf(POPOVER_TOOLTIP, module)
.addDecorator((getStory) => (
<div
className="slds-p-around_medium slds-m-horizontal_x-large"
style={{
margin: '150px auto',
width: '500px',
}}
>
<IconSettings iconPath="/assets/icons">{getStory()}</IconSettings>
</div>
))
.add('Base', () => <Base />)
.add('Learn More', () => <LearnMoreExample />)
.add('Button Group', () => <ButtonGroupExample />)
.add('Button', () => <ButtonExample />)
.add('Open', () =>
getPopoverTooltip({
align: 'bottom',
isOpen: true,
id: 'myPopoverId',
dialogClassName: 'dialog-classname',
content,
})
)
.add('Alignment (Button)', () =>
getPopoverTooltipAlign({
id: 'myPopoverId',
isOpen: true,
content,
trigger: <Button label="Trigger Tooltip" />,
})
)
.add('Alignment (span)', () =>
getPopoverTooltipAlign({
id: 'myPopoverId',
isOpen: true,
content,
trigger: (
<span tabIndex="0" key="trigger">
Trigger Tooltip
</span>
),
})
)
.add('Alignment (icon)', () =>
getPopoverTooltipAlign({
id: 'myPopoverId',
isOpen: true,
content: <span>{content}</span>, // react/no-unescaped-entities
trigger: (
<Icon
assistiveText={{ label: 'Case Icon' }}
category="standard"
name="case"
size="small"
tabIndex="0"
/>
),
})
)
.add('With Delay', () => <WithDelay />)
.add('With Anchored Nubbin', () => <AnchoredNubbin />);