Migrate StartNewConversation to storybook
This commit is contained in:
parent
309332d943
commit
1ca3ec47f8
2 changed files with 38 additions and 23 deletions
|
@ -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>
|
||||
```
|
38
ts/components/StartNewConversation.stories.tsx
Normal file
38
ts/components/StartNewConversation.stories.tsx
Normal 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} />;
|
||||
});
|
Loading…
Add table
Reference in a new issue