|
| 1 | +import * as React from 'react'; |
| 2 | +import { storiesOf } from '@storybook/react'; |
| 3 | +import { action } from '@storybook/addon-actions'; |
| 4 | +import SandboxCard, { Props } from './'; |
| 5 | +import * as fake from './fixtures'; |
| 6 | +import { ThemeDecorator } from '../../stories/decorators'; |
| 7 | + |
| 8 | +const stories = storiesOf('components/SandboxCard', module).addDecorator( |
| 9 | + ThemeDecorator |
| 10 | +); |
| 11 | + |
| 12 | +const createSandboxStory = ({ |
| 13 | + sandbox = fake.sandbox(), |
| 14 | + selectSandbox = action('selectSandbox'), |
| 15 | + small, |
| 16 | + noHeight, |
| 17 | + defaultHeight, |
| 18 | + noMargin, |
| 19 | +}: Partial<Props>) => () => ( |
| 20 | + <SandboxCard |
| 21 | + sandbox={sandbox} |
| 22 | + selectSandbox={selectSandbox} |
| 23 | + small={small} |
| 24 | + noHeight={noHeight} |
| 25 | + defaultHeight={defaultHeight} |
| 26 | + noMargin={noMargin} |
| 27 | + /> |
| 28 | +); |
| 29 | + |
| 30 | +stories.add('basic', createSandboxStory({})); |
| 31 | + |
| 32 | +stories.add('small', createSandboxStory({ small: true })); |
| 33 | + |
| 34 | +stories.add('no height', createSandboxStory({ noHeight: true })); |
| 35 | + |
| 36 | +stories.add('default height', createSandboxStory({ defaultHeight: 500 })); |
| 37 | + |
| 38 | +stories.add('no margin', createSandboxStory({ noMargin: true })); |
| 39 | + |
| 40 | +stories.add('popular', createSandboxStory({ sandbox: fake.popularSandbox() })); |
| 41 | + |
| 42 | +stories.add( |
| 43 | + 'many tags', |
| 44 | + createSandboxStory({ sandbox: fake.sandboxWithManyTags() }) |
| 45 | +); |
| 46 | + |
| 47 | +stories.add( |
| 48 | + 'long title', |
| 49 | + createSandboxStory({ sandbox: fake.sandboxWithLongTitle() }) |
| 50 | +); |
| 51 | + |
| 52 | +stories.add( |
| 53 | + 'long description', |
| 54 | + createSandboxStory({ |
| 55 | + sandbox: fake.sandboxWithLongDescription(), |
| 56 | + }) |
| 57 | +); |
| 58 | + |
| 59 | +stories.add( |
| 60 | + 'null author', |
| 61 | + createSandboxStory({ |
| 62 | + sandbox: fake.sandboxWithNullAuthor(), |
| 63 | + }) |
| 64 | +); |
| 65 | + |
| 66 | +stories.add( |
| 67 | + 'undefined author', |
| 68 | + createSandboxStory({ |
| 69 | + sandbox: fake.sandboxWithUndefinedAuthor(), |
| 70 | + }) |
| 71 | +); |
| 72 | + |
| 73 | +stories.add( |
| 74 | + 'null screenshot url', |
| 75 | + createSandboxStory({ |
| 76 | + sandbox: fake.sandboxWithNullScreenshotUrl(), |
| 77 | + }) |
| 78 | +); |
| 79 | + |
| 80 | +stories.add( |
| 81 | + 'undefined screenshot url', |
| 82 | + createSandboxStory({ |
| 83 | + sandbox: fake.sandboxWithUndefinedScreenshotUrl(), |
| 84 | + }) |
| 85 | +); |
0 commit comments