Migrate ScrollDownButton to Storybook

Co-authored-by: Chris Svenningsen <chris@carbonfive.com>
This commit is contained in:
Sidney Keese 2020-08-26 14:09:30 -07:00 committed by Josh Perez
parent 15c7e9bf72
commit b3a54870b8
3 changed files with 39 additions and 26 deletions

View file

@ -1,25 +0,0 @@
### No new messages
```jsx
<util.ConversationContext theme={util.theme} ios={util.ios}>
<ScrollDownButton
withNewMessages={false}
conversationId="id-1"
scrollDown={id => console.log('scrollDown', id)}
i18n={util.i18n}
/>
</util.ConversationContext>
```
### With new messages
```jsx
<util.ConversationContext theme={util.theme} ios={util.ios}>
<ScrollDownButton
withNewMessages={true}
conversationId="id-2"
scrollDown={id => console.log('scrollDown', id)}
i18n={util.i18n}
/>
</util.ConversationContext>
```

View file

@ -0,0 +1,38 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { boolean } from '@storybook/addon-knobs';
// @ts-ignore
import { setup as setupI18n } from '../../../js/modules/i18n';
// @ts-ignore
import enMessages from '../../../_locales/en/messages.json';
import { Props, ScrollDownButton } from './ScrollDownButton';
const i18n = setupI18n('en', enMessages);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
withNewMessages: boolean(
'withNewMessages',
overrideProps.withNewMessages || false
),
scrollDown: action('scrollDown'),
conversationId: 'fake-conversation-id',
});
const stories = storiesOf('Components/Conversation/ScrollDownButton', module);
stories.add('No New Messages', () => {
const props = createProps();
return <ScrollDownButton {...props} />;
});
stories.add('New Messages', () => {
const props = createProps({ withNewMessages: true });
return <ScrollDownButton {...props} />;
});

View file

@ -3,7 +3,7 @@ import classNames from 'classnames';
import { LocalizerType } from '../../types/Util';
type Props = {
export type Props = {
withNewMessages: boolean;
conversationId: string;