1 | import React from 'react'
|
2 | import { storiesOf } from '@storybook/react'
|
3 | import { action } from '@storybook/addon-actions'
|
4 | import styled from 'styled-components'
|
5 | import Chance from 'chance'
|
6 | import MenuDropdown from '../src/dropdown/MenuDropdown'
|
7 | import VirtualizedDropdown from '../src/dropdown/VirtualizedDropdown'
|
8 |
|
9 | const chance = new Chance()
|
10 |
|
11 | const options = [
|
12 | { text: 'Option 1', value: '1' },
|
13 | { text: 'Long Option 2', value: '2' },
|
14 | { text: 'Option 3', value: '3' },
|
15 | { text: 'Long Long Option 4', value: '4' },
|
16 | { text: 'Option 5', value: '5' },
|
17 | ]
|
18 |
|
19 | const manyOptions = chance
|
20 | .unique(() => chance.word({ syllables: 4 }), 10000)
|
21 | .map((text, value) => ({ value, text }))
|
22 |
|
23 | const MenuBar = styled.div`
|
24 | background-color: #eee;
|
25 | height: 4em;
|
26 | padding: 0.5em 1em;
|
27 | `
|
28 |
|
29 | storiesOf('Dropdowns', module)
|
30 | .add('Right Menu', () => (
|
31 | <MenuBar>
|
32 | <MenuDropdown
|
33 | style={{ float: 'right' }}
|
34 | options={options}
|
35 | onOptionSelected={action('selected option:')}
|
36 | buttonProps={{ basic: true, text: 'C Actions', primary: true }}
|
37 | />
|
38 | </MenuBar>
|
39 | ))
|
40 | .add('Left Menu', () => (
|
41 | <MenuBar>
|
42 | <MenuDropdown
|
43 | options={options}
|
44 | onOptionSelected={action('selected option:')}
|
45 | popperPlacement="bottom-start"
|
46 | />
|
47 | </MenuBar>
|
48 | ))
|
49 | .add('VirtualizedDropdown', () => (
|
50 | <VirtualizedDropdown options={manyOptions} onChange={action('selected item:')} />
|
51 | ))
|