Migrate StartNewConversation to storybook

This commit is contained in:
Sidney Keese 2020-08-20 15:07:13 -07:00 committed by Josh Perez
parent 309332d943
commit 1ca3ec47f8
2 changed files with 38 additions and 23 deletions

View file

@ -1,23 +0,0 @@
#### With full phone number
```jsx
<util.LeftPaneContext theme={util.theme}>
<StartNewConversation
phoneNumber="(202) 555-0011"
onClick={result => console.log('onClick', result)}
i18n={util.i18n}
/>
</util.LeftPaneContext>
```
#### With partial phone number
```jsx
<util.LeftPaneContext theme={util.theme}>
<StartNewConversation
phoneNumber="202"
onClick={result => console.log('onClick', result)}
i18n={util.i18n}
/>
</util.LeftPaneContext>
```

View file

@ -0,0 +1,38 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { Props, StartNewConversation } from './StartNewConversation';
// @ts-ignore
import { setup as setupI18n } from '../../js/modules/i18n';
// @ts-ignore
import enMessages from '../../_locales/en/messages.json';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
const i18n = setupI18n('en', enMessages);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
onClick: action('onClick'),
phoneNumber: text('phoneNumber', overrideProps.phoneNumber || ''),
});
const stories = storiesOf('Components/StartNewConversation', module);
stories.add('Full Phone Number', () => {
const props = createProps({
phoneNumber: '(202) 555-0011',
});
return <StartNewConversation {...props} />;
});
stories.add('Partial Phone Number', () => {
const props = createProps({
phoneNumber: '202',
});
return <StartNewConversation {...props} />;
});