Migrate Timeline, TimelineLoadingRow to storybook
This commit is contained in:
parent
25dabd56fd
commit
1894ff0dc1
6 changed files with 396 additions and 388 deletions
41
ts/components/conversation/TimelineLoadingRow.stories.tsx
Normal file
41
ts/components/conversation/TimelineLoadingRow.stories.tsx
Normal file
|
@ -0,0 +1,41 @@
|
|||
import * as React from 'react';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import { date, number, select } from '@storybook/addon-knobs';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import { Props, TimelineLoadingRow } from './TimelineLoadingRow';
|
||||
|
||||
const story = storiesOf('Components/Conversation/TimelineLoadingRow', module);
|
||||
|
||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||
state: select(
|
||||
'state',
|
||||
{ idle: 'idle', countdown: 'countdown', loading: 'loading' },
|
||||
overrideProps.state || 'idle'
|
||||
),
|
||||
duration: number('duration', overrideProps.duration || 0),
|
||||
expiresAt: date('expiresAt', new Date(overrideProps.expiresAt || Date.now())),
|
||||
onComplete: action('onComplete'),
|
||||
});
|
||||
|
||||
story.add('Idle', () => {
|
||||
const props = createProps();
|
||||
|
||||
return <TimelineLoadingRow {...props} />;
|
||||
});
|
||||
|
||||
story.add('Countdown', () => {
|
||||
const props = createProps({
|
||||
state: 'countdown',
|
||||
duration: 40000,
|
||||
expiresAt: Date.now() + 20000,
|
||||
});
|
||||
|
||||
return <TimelineLoadingRow {...props} />;
|
||||
});
|
||||
|
||||
story.add('Loading', () => {
|
||||
const props = createProps({ state: 'loading' });
|
||||
|
||||
return <TimelineLoadingRow {...props} />;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue