Migrate LastSeenIndicator to Storybook

This commit is contained in:
Chris Svenningsen 2020-08-24 06:57:00 -07:00 committed by Josh Perez
parent 15e817c3e2
commit 58db34c5e8
3 changed files with 33 additions and 16 deletions

View file

@ -1,15 +0,0 @@
### One
```jsx
<util.ConversationContext theme={util.theme} ios={util.ios}>
<LastSeenIndicator count={1} i18n={util.i18n} />
</util.ConversationContext>
```
### More than one
```jsx
<util.ConversationContext theme={util.theme} ios={util.ios}>
<LastSeenIndicator count={2} i18n={util.i18n} />
</util.ConversationContext>
```

View file

@ -0,0 +1,32 @@
import * as React from 'react';
import { number } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { LastSeenIndicator, Props } from './LastSeenIndicator';
// @ts-ignore
import { setup as setupI18n } from '../../../js/modules/i18n';
// @ts-ignore
import enMessages from '../../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
const story = storiesOf('Components/Conversation/LastSeenIndicator', module);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
count: number('count', overrideProps.count || 1),
i18n,
});
story.add('One', () => {
const props = createProps();
return <LastSeenIndicator {...props} />;
});
story.add('More than One', () => {
const props = createProps({
count: 5,
});
return <LastSeenIndicator {...props} />;
});

View file

@ -2,7 +2,7 @@ import React from 'react';
import { LocalizerType } from '../../types/Util';
type Props = {
export type Props = {
count: number;
i18n: LocalizerType;
};