|
1 | 1 | import centered from '@storybook/addon-centered/react'; |
2 | 2 | import { storiesOf } from '@storybook/react'; |
3 | | -import React, { useState } from 'react'; |
4 | | - |
5 | | -import Select from '../Select'; |
| 3 | +import React from 'react'; |
| 4 | +import { action } from '@storybook/addon-actions'; |
| 5 | +import { select, text } from '@storybook/addon-knobs/react'; |
6 | 6 | import Tooltip from '../Tooltip'; |
| 7 | +import { POSITIONS } from '../constants'; |
7 | 8 |
|
8 | 9 | const id = 'tooltipDemo'; |
9 | 10 |
|
10 | 11 | storiesOf('Tooltip', module) |
11 | 12 | .addDecorator(centered) |
12 | 13 | .add('All Knobs', () => { |
13 | | - const [position, setPosition] = useState('top-left'); |
14 | | - |
15 | | - const handleChange = ({ target: { value } }) => { |
16 | | - setPosition(value); |
17 | | - }; |
| 14 | + let position = select('positions', POSITIONS, 'top-left'); |
| 15 | + let content = text('content', 'I am a tool tip'); |
18 | 16 |
|
19 | 17 | return ( |
20 | | - <div> |
| 18 | + <> |
21 | 19 | <hx-icon id={id} type="help-circle" /> |
22 | | - <Tooltip id={id} position={position}> |
23 | | - Some Message |
| 20 | + <Tooltip |
| 21 | + id={id} |
| 22 | + position={position} |
| 23 | + onOpen={action('onOpen')} |
| 24 | + onClose={action('onClose')} |
| 25 | + onReposition={action('onReposition')} |
| 26 | + > |
| 27 | + {content} |
24 | 28 | </Tooltip> |
25 | | - <div style={{ marginTop: 100, width: 300 }}> |
26 | | - <Select id="selectTooltipDemo" label="Position" onChange={handleChange}> |
27 | | - <option value="top-left">Top Left</option> |
28 | | - <option value="top-center">Top Center</option> |
29 | | - <option value="top-right">Top Right</option> |
30 | | - <option value="right-top">Right Top</option> |
31 | | - <option value="right-middle">Right Middle</option> |
32 | | - <option value="right-bottom">Right Bottom</option> |
33 | | - <option value="bottom-right">Bottom Right</option> |
34 | | - <option value="bottom-center">Bottom Center</option> |
35 | | - <option value="bottom-left">Bottom Left</option> |
36 | | - <option value="left-bottom">Left Bottom</option> |
37 | | - <option value="left-middle">Left Middle</option> |
38 | | - <option value="left-top">Left Top</option> |
39 | | - </Select> |
40 | | - </div> |
41 | | - </div> |
| 29 | + </> |
42 | 30 | ); |
43 | 31 | }); |
0 commit comments