From d1d1436fde3bcd6934f62d2b6bcd67eb30c3ab84 Mon Sep 17 00:00:00 2001 From: Sidney Keese Date: Tue, 18 Aug 2020 10:21:53 -0700 Subject: [PATCH] Migrate composition input to storybook --- ts/components/CompositionInput.md | 12 --- ts/components/CompositionInput.stories.tsx | 104 +++++++++++++++++++++ 2 files changed, 104 insertions(+), 12 deletions(-) delete mode 100644 ts/components/CompositionInput.md create mode 100644 ts/components/CompositionInput.stories.tsx diff --git a/ts/components/CompositionInput.md b/ts/components/CompositionInput.md deleted file mode 100644 index 705ee852c8..0000000000 --- a/ts/components/CompositionInput.md +++ /dev/null @@ -1,12 +0,0 @@ -#### Default - -```jsx - -
- console.log('onSubmit', s)} - /> -
-
-``` diff --git a/ts/components/CompositionInput.stories.tsx b/ts/components/CompositionInput.stories.tsx new file mode 100644 index 0000000000..f54f062ec6 --- /dev/null +++ b/ts/components/CompositionInput.stories.tsx @@ -0,0 +1,104 @@ +import * as React from 'react'; + +import { storiesOf } from '@storybook/react'; +import { action } from '@storybook/addon-actions'; + +import { CompositionInput, Props } from './CompositionInput'; + +// tslint:disable-next-line +import 'draft-js/dist/Draft.css'; + +// @ts-ignore +import { setup as setupI18n } from '../../js/modules/i18n'; + +// @ts-ignore +import enMessages from '../../_locales/en/messages.json'; +import { boolean, select } from '@storybook/addon-knobs'; + +const i18n = setupI18n('en', enMessages); + +const story = storiesOf('Components/CompositionInput', module); + +const createProps = (overrideProps: Partial = {}): Props => ({ + i18n, + disabled: boolean('disabled', overrideProps.disabled || false), + onSubmit: action('onSubmit'), + onEditorSizeChange: action('onEditorSizeChange'), + onEditorStateChange: action('onEditorStateChange'), + onTextTooLong: action('onTextTooLong'), + startingText: overrideProps.startingText || undefined, + clearQuotedMessage: action('clearQuotedMessage'), + getQuotedMessage: action('getQuotedMessage'), + onPickEmoji: action('onPickEmoji'), + large: boolean('large', overrideProps.large || false), + skinTone: select( + 'skinTone', + { + skinTone0: 0, + skinTone1: 1, + skinTone2: 2, + skinTone3: 3, + skinTone4: 4, + skinTone5: 5, + }, + overrideProps.skinTone || undefined + ), +}); + +story.add('Default', () => { + const props = createProps(); + + return ; +}); + +story.add('Large', () => { + const props = createProps({ + large: true, + }); + + return ; +}); + +story.add('Disabled', () => { + const props = createProps({ + disabled: true, + }); + + return ; +}); + +story.add('Starting Text', () => { + const props = createProps({ + startingText: "here's some starting text", + }); + + return ; +}); + +story.add('Multiline Text', () => { + const props = createProps({ + startingText: `here's some starting text +and more on another line +and yet another line +and yet another line +and yet another line +and yet another line +and yet another line +and yet another line +and we're done`, + }); + + return ; +}); + +story.add('Emojis', () => { + const props = createProps({ + startingText: `⁣😐😐😐😐😐😐😐 +😐😐😐😐😐😐😐 +😐😐😐😂⁣😐😐😐 +😐😐😐😐😐😐😐 +😐😐😐😐😐😐😐`, + }); + + return ; +});