UNPKG

1.43 kBJavaScriptView Raw
1import React from 'react'
2import { storiesOf } from '@storybook/react'
3import { action } from '@storybook/addon-actions'
4import styled from 'styled-components'
5import Chance from 'chance'
6import MenuDropdown from '../src/dropdown/MenuDropdown'
7import VirtualizedDropdown from '../src/dropdown/VirtualizedDropdown'
8
9const chance = new Chance()
10
11const 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
19const manyOptions = chance
20 .unique(() => chance.word({ syllables: 4 }), 10000)
21 .map((text, value) => ({ value, text }))
22
23const MenuBar = styled.div`
24 background-color: #eee;
25 height: 4em;
26 padding: 0.5em 1em;
27`
28
29storiesOf('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 ))