Migrate ShortcutGuide to Storybook
This commit is contained in:
parent
6f4965fd5a
commit
25ab4df9cc
2 changed files with 47 additions and 7 deletions
|
@ -1,7 +0,0 @@
|
|||
```jsx
|
||||
<util.ConversationContext theme={util.theme}>
|
||||
<div style={{ position: 'relative', height: '500px', width: '600px; }}>
|
||||
<ShortcutGuide i18n={util.i18n} />
|
||||
</div>
|
||||
</util.ConversationContext>
|
||||
```
|
47
ts/components/ShortcutGuide.stories.tsx
Normal file
47
ts/components/ShortcutGuide.stories.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
import * as React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import { boolean, select } from '@storybook/addon-knobs';
|
||||
|
||||
// @ts-ignore
|
||||
import { setup as setupI18n } from '../../js/modules/i18n';
|
||||
|
||||
// @ts-ignore
|
||||
import enMessages from '../../_locales/en/messages.json';
|
||||
|
||||
import { Props, ShortcutGuide } from './ShortcutGuide';
|
||||
|
||||
const i18n = setupI18n('en', enMessages);
|
||||
const story = storiesOf('Components/ShortcutGuide', module);
|
||||
|
||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||
i18n,
|
||||
close: action('close'),
|
||||
hasInstalledStickers: boolean(
|
||||
'hasInstalledStickers',
|
||||
overrideProps.hasInstalledStickers || false
|
||||
),
|
||||
platform: select(
|
||||
'platform',
|
||||
{
|
||||
macOS: 'darwin',
|
||||
other: 'other',
|
||||
},
|
||||
overrideProps.platform || 'other'
|
||||
),
|
||||
});
|
||||
|
||||
story.add('Default', () => {
|
||||
const props = createProps({});
|
||||
return <ShortcutGuide {...props} />;
|
||||
});
|
||||
|
||||
story.add('Mac', () => {
|
||||
const props = createProps({ platform: 'darwin' });
|
||||
return <ShortcutGuide {...props} />;
|
||||
});
|
||||
|
||||
story.add('Has Stickers', () => {
|
||||
const props = createProps({ hasInstalledStickers: true });
|
||||
return <ShortcutGuide {...props} />;
|
||||
});
|
Loading…
Reference in a new issue