diff --git a/ts/components/conversation/SafetyNumberNotification.md b/ts/components/conversation/SafetyNumberNotification.md deleted file mode 100644 index 2e62922e12..0000000000 --- a/ts/components/conversation/SafetyNumberNotification.md +++ /dev/null @@ -1,33 +0,0 @@ -### In group conversation - -```jsx - - console.log('onVerify')} - /> - -``` - -### In one-on-one conversation - -```jsx - - console.log('onVerify')} - /> - -``` diff --git a/ts/components/conversation/SafetyNumberNotification.stories.tsx b/ts/components/conversation/SafetyNumberNotification.stories.tsx new file mode 100644 index 0000000000..2045f2c52f --- /dev/null +++ b/ts/components/conversation/SafetyNumberNotification.stories.tsx @@ -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 => ({ + id: '', + title: text('contact title', props.title || ''), +}); + +const createProps = (overrideProps: Partial = {}): 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 ; +}); + +stories.add('Direct Conversation', () => { + const props = createProps({ + isGroup: false, + contact: createContact({ + title: 'Mr. Fire', + }), + }); + + return ; +}); diff --git a/ts/components/conversation/SafetyNumberNotification.tsx b/ts/components/conversation/SafetyNumberNotification.tsx index 2651ec7034..b03af2750c 100644 --- a/ts/components/conversation/SafetyNumberNotification.tsx +++ b/ts/components/conversation/SafetyNumberNotification.tsx @@ -4,7 +4,7 @@ import { ContactName } from './ContactName'; import { Intl } from '../Intl'; import { LocalizerType } from '../../types/Util'; -interface ContactType { +export interface ContactType { id: string; phoneNumber?: string; profileName?: string; @@ -25,7 +25,7 @@ export type PropsActions = { showIdentity: (id: string) => void; }; -type Props = PropsData & PropsHousekeeping & PropsActions; +export type Props = PropsData & PropsHousekeeping & PropsActions; export class SafetyNumberNotification extends React.Component { public render() {