signal-desktop/ts/components/conversation/media-gallery/MediaGallery.stories.tsx

67 lines
1.7 KiB
TypeScript
Raw Normal View History

2020-08-21 15:13:55 +00:00
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { setup as setupI18n } from '../../../../js/modules/i18n';
import enMessages from '../../../../_locales/en/messages.json';
2020-08-26 00:39:24 +00:00
import {
createPreparedMediaItems,
createRandomDocuments,
createRandomMedia,
days,
now,
} from './AttachmentSection.stories';
2020-08-21 15:13:55 +00:00
import { MediaGallery, Props } from './MediaGallery';
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/Conversation/MediaGallery/MediaGallery',
module
);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
onItemClick: action('onItemClick'),
documents: overrideProps.documents || [],
media: overrideProps.media || [],
});
story.add('Populated', () => {
2020-08-26 00:39:24 +00:00
const documents = createRandomDocuments(now, days(1)).slice(0, 1);
const media = createPreparedMediaItems(createRandomMedia);
2020-08-21 15:13:55 +00:00
const props = createProps({ documents, media });
return <MediaGallery {...props} />;
});
story.add('No Documents', () => {
2020-08-26 00:39:24 +00:00
const media = createPreparedMediaItems(createRandomMedia);
2020-08-21 15:13:55 +00:00
const props = createProps({ media });
return <MediaGallery {...props} />;
});
story.add('No Media', () => {
2020-08-26 00:39:24 +00:00
const documents = createPreparedMediaItems(createRandomDocuments);
2020-08-21 15:13:55 +00:00
const props = createProps({ documents });
return <MediaGallery {...props} />;
});
story.add('One Each', () => {
const media = createRandomMedia(now, days(1)).slice(0, 1);
const documents = createRandomDocuments(now, days(1)).slice(0, 1);
const props = createProps({ documents, media });
return <MediaGallery {...props} />;
});
story.add('Empty', () => {
const props = createProps();
return <MediaGallery {...props} />;
});