Migrate SafetyNumberNotification to Storybook
This commit is contained in:
parent
7b75f8bb2e
commit
de72a2f6c6
3 changed files with 59 additions and 35 deletions
|
@ -1,33 +0,0 @@
|
||||||
### In group conversation
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
<util.ConversationContext theme={util.theme}>
|
|
||||||
<SafetyNumberNotification
|
|
||||||
i18n={util.i18n}
|
|
||||||
isGroup={true}
|
|
||||||
contact={{
|
|
||||||
phoneNumber: '(202) 500-1000',
|
|
||||||
profileName: 'Mr. Fire',
|
|
||||||
title: 'Mr. Fire',
|
|
||||||
}}
|
|
||||||
onVerify={() => console.log('onVerify')}
|
|
||||||
/>
|
|
||||||
</util.ConversationContext>
|
|
||||||
```
|
|
||||||
|
|
||||||
### In one-on-one conversation
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
<util.ConversationContext theme={util.theme}>
|
|
||||||
<SafetyNumberNotification
|
|
||||||
i18n={util.i18n}
|
|
||||||
isGroup={false}
|
|
||||||
contact={{
|
|
||||||
phoneNumber: '(202) 500-1000',
|
|
||||||
profileName: 'Mr. Fire',
|
|
||||||
title: 'Mr. Fire',
|
|
||||||
}}
|
|
||||||
onVerify={() => console.log('onVerify')}
|
|
||||||
/>
|
|
||||||
</util.ConversationContext>
|
|
||||||
```
|
|
|
@ -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} />;
|
||||||
|
});
|
|
@ -4,7 +4,7 @@ import { ContactName } from './ContactName';
|
||||||
import { Intl } from '../Intl';
|
import { Intl } from '../Intl';
|
||||||
import { LocalizerType } from '../../types/Util';
|
import { LocalizerType } from '../../types/Util';
|
||||||
|
|
||||||
interface ContactType {
|
export interface ContactType {
|
||||||
id: string;
|
id: string;
|
||||||
phoneNumber?: string;
|
phoneNumber?: string;
|
||||||
profileName?: string;
|
profileName?: string;
|
||||||
|
@ -25,7 +25,7 @@ export type PropsActions = {
|
||||||
showIdentity: (id: string) => void;
|
showIdentity: (id: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = PropsData & PropsHousekeeping & PropsActions;
|
export type Props = PropsData & PropsHousekeeping & PropsActions;
|
||||||
|
|
||||||
export class SafetyNumberNotification extends React.Component<Props> {
|
export class SafetyNumberNotification extends React.Component<Props> {
|
||||||
public render() {
|
public render() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue