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

69 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-08-21 15:13:55 +00:00
import * as React from 'react';
import { action } from '@storybook/addon-actions';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../../util/setupI18n';
2020-08-21 15:13:55 +00:00
import enMessages from '../../../../_locales/en/messages.json';
2020-08-26 00:39:24 +00:00
import {
createPreparedMediaItems,
createRandomDocuments,
createRandomMedia,
days,
now,
} from './AttachmentSection.stories';
import type { Props } from './MediaGallery';
import { MediaGallery } from './MediaGallery';
2020-08-21 15:13:55 +00:00
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/MediaGallery/MediaGallery',
};
2020-08-21 15:13:55 +00:00
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
onItemClick: action('onItemClick'),
documents: overrideProps.documents || [],
media: overrideProps.media || [],
});
2022-06-07 00:48:02 +00:00
export const Populated = (): JSX.Element => {
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} />;
2022-06-07 00:48:02 +00:00
};
2020-08-21 15:13:55 +00:00
2022-06-07 00:48:02 +00:00
export const NoDocuments = (): JSX.Element => {
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} />;
2022-06-07 00:48:02 +00:00
};
2020-08-21 15:13:55 +00:00
2022-06-07 00:48:02 +00:00
export const NoMedia = (): JSX.Element => {
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} />;
2022-06-07 00:48:02 +00:00
};
2020-08-21 15:13:55 +00:00
2022-06-07 00:48:02 +00:00
export const OneEach = (): JSX.Element => {
2020-08-21 15:13:55 +00:00
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} />;
2022-06-07 00:48:02 +00:00
};
2020-08-21 15:13:55 +00:00
2022-06-07 00:48:02 +00:00
export const Empty = (): JSX.Element => {
2020-08-21 15:13:55 +00:00
const props = createProps();
return <MediaGallery {...props} />;
2022-06-07 00:48:02 +00:00
};