diff --git a/ts/components/MessageBodyHighlight.md b/ts/components/MessageBodyHighlight.md deleted file mode 100644 index e250bf4f03..0000000000 --- a/ts/components/MessageBodyHighlight.md +++ /dev/null @@ -1,41 +0,0 @@ -Basic replacement - -```jsx - -``` - -With no replacement - -```jsx - -``` - -With two replacements - -```jsx - -``` - -With emoji, newlines, and URLs - -```jsx - -``` - -No jumbomoji - -```jsx - -``` diff --git a/ts/components/MessageBodyHighlight.stories.tsx b/ts/components/MessageBodyHighlight.stories.tsx new file mode 100644 index 0000000000..6c846af89c --- /dev/null +++ b/ts/components/MessageBodyHighlight.stories.tsx @@ -0,0 +1,63 @@ +import * as React from 'react'; +import { storiesOf } from '@storybook/react'; +import { text, withKnobs } from '@storybook/addon-knobs'; + +// @ts-ignore +import { setup as setupI18n } from '../../js/modules/i18n'; +// @ts-ignore +import enMessages from '../../_locales/en/messages.json'; + +import { MessageBodyHighlight, Props } from './MessageBodyHighlight'; + +const i18n = setupI18n('en', enMessages); + +const story = storiesOf('Components/MessageBodyHighlight', module); + +story.addDecorator((withKnobs as any)({ escapeHTML: false })); + +const createProps = (overrideProps: Partial = {}): Props => ({ + i18n, + text: text('text', overrideProps.text || ''), +}); + +story.add('Basic', () => { + const props = createProps({ + text: 'This is before <>Inside<> This is after.', + }); + + return ; +}); + +story.add('No Replacement', () => { + const props = createProps({ + text: 'All\nplain\ntext šŸ”„ http://somewhere.com', + }); + + return ; +}); + +story.add('Two Replacements', () => { + const props = createProps({ + text: + 'Begin <>Inside #1<> This is between the two <>Inside #2<> End.', + }); + + return ; +}); + +story.add('Emoji + Newlines + URLs', () => { + const props = createProps({ + text: + '\nhttp://somewhere.com\n\nšŸ”„ Before -- <>A šŸ”„ inside<> -- After šŸ”„', + }); + + return ; +}); + +story.add('No Jumbomoji', () => { + const props = createProps({ + text: 'šŸ”„', + }); + + return ; +}); diff --git a/ts/components/MessageBodyHighlight.tsx b/ts/components/MessageBodyHighlight.tsx index 642adb4835..37d3f99814 100644 --- a/ts/components/MessageBodyHighlight.tsx +++ b/ts/components/MessageBodyHighlight.tsx @@ -8,7 +8,7 @@ import { SizeClassType } from './emoji/lib'; import { LocalizerType, RenderTextCallbackType } from '../types/Util'; -interface Props { +export interface Props { text: string; i18n: LocalizerType; }