|
1 | 1 | import React from 'react'
|
| 2 | +import { withA11y } from '@storybook/addon-a11y' |
| 3 | +import { withKnobs, text, boolean, select } from "@storybook/addon-knobs" |
| 4 | +import { action } from '@storybook/addon-actions' |
2 | 5 |
|
3 | 6 | import Button from '.'
|
4 | 7 |
|
5 | 8 | export default {
|
6 |
| - title: 'Button', |
| 9 | + title: 'Components|Button', |
7 | 10 | component: Button,
|
| 11 | + decorators: [withA11y, withKnobs] |
8 | 12 | }
|
9 | 13 |
|
10 |
| -export const withText = () => ( |
11 |
| - <Button type="primary"> |
12 |
| - With a text |
| 14 | +const variations = ['primary', 'secondary', 'tertiary', 'danger', 'danger-tertiary', 'inverted-tertiary'] |
| 15 | + |
| 16 | +export const Default = () => ( |
| 17 | + <Button |
| 18 | + variation={select('Variation', variations, 'primary')} |
| 19 | + isLoading={boolean('Is loading', false)} |
| 20 | + disabled={boolean('Disabled', false)} |
| 21 | + block={boolean('Block', false)} |
| 22 | + size={select('Size', ['small', 'regular', 'large'], 'regular')} |
| 23 | + onClick={action('button-click')} |
| 24 | + onFocus={action('button-focus')} |
| 25 | + > |
| 26 | + {text("Label", "With a text")} |
| 27 | + </Button> |
| 28 | +) |
| 29 | + |
| 30 | +export const withLoadingState = () => ( |
| 31 | + <Button |
| 32 | + isLoading={true} |
| 33 | + > |
| 34 | + Loading |
| 35 | + </Button> |
| 36 | +) |
| 37 | + |
| 38 | +export const withDiffentVariations = () => ( |
| 39 | + <> |
| 40 | + {variations.map(variation => ( |
| 41 | + <> |
| 42 | + <Button variation={variation}>{variation}</Button> |
| 43 | + <br/> |
| 44 | + <br/> |
| 45 | + </> |
| 46 | + ))} |
| 47 | + </> |
| 48 | +) |
| 49 | + |
| 50 | +export const withOnMouseEvents = () => ( |
| 51 | + <Button |
| 52 | + onMouseDown={action('button-on-mouse-down')} |
| 53 | + onMouseEnter={action('button-on-mouse-enter')} |
| 54 | + onMouseOver={action('button-on-mouse-over')} |
| 55 | + onMouseLeave={action('button-on-mouse-leave')} |
| 56 | + onMouseOut={action('button-on-mouse-out')} |
| 57 | + onMouseUp={action('button-on-mouse-up')} |
| 58 | + > |
| 59 | + Button |
13 | 60 | </Button>
|
14 | 61 | )
|
0 commit comments