Migrate SafetyNumberNotification to Storybook
This commit is contained in:
parent
7b75f8bb2e
commit
de72a2f6c6
3 changed files with 59 additions and 35 deletions
|
@ -0,0 +1,57 @@
|
|||
import * as React from 'react';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { boolean, text } from '@storybook/addon-knobs';
|
||||
|
||||
// @ts-ignore
|
||||
import { setup as setupI18n } from '../../../js/modules/i18n';
|
||||
|
||||
// @ts-ignore
|
||||
import enMessages from '../../../_locales/en/messages.json';
|
||||
|
||||
import {
|
||||
ContactType,
|
||||
Props,
|
||||
SafetyNumberNotification,
|
||||
} from './SafetyNumberNotification';
|
||||
|
||||
const i18n = setupI18n('en', enMessages);
|
||||
|
||||
const createContact = (props: Partial<ContactType>): ContactType => ({
|
||||
id: '',
|
||||
title: text('contact title', props.title || ''),
|
||||
});
|
||||
|
||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||
i18n,
|
||||
contact: overrideProps.contact || ({} as ContactType),
|
||||
isGroup: boolean('isGroup', overrideProps.isGroup || false),
|
||||
showIdentity: action('showIdentity'),
|
||||
});
|
||||
|
||||
const stories = storiesOf(
|
||||
'Components/Conversation/SafetyNumberNotification',
|
||||
module
|
||||
);
|
||||
|
||||
stories.add('Group Conversation', () => {
|
||||
const props = createProps({
|
||||
isGroup: true,
|
||||
contact: createContact({
|
||||
title: 'Mr. Fire',
|
||||
}),
|
||||
});
|
||||
|
||||
return <SafetyNumberNotification {...props} />;
|
||||
});
|
||||
|
||||
stories.add('Direct Conversation', () => {
|
||||
const props = createProps({
|
||||
isGroup: false,
|
||||
contact: createContact({
|
||||
title: 'Mr. Fire',
|
||||
}),
|
||||
});
|
||||
|
||||
return <SafetyNumberNotification {...props} />;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue