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

72 lines
2 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// 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 => ({
2022-12-20 17:50:23 +00:00
conversationId: '123',
2020-08-21 15:13:55 +00:00
documents: overrideProps.documents || [],
2022-12-20 17:50:23 +00:00
i18n,
loadMediaItems: action('loadMediaItems'),
2020-08-21 15:13:55 +00:00
media: overrideProps.media || [],
2022-12-20 17:50:23 +00:00
saveAttachment: action('saveAttachment'),
showLightboxWithMedia: action('showLightboxWithMedia'),
2020-08-21 15:13:55 +00:00
});
2022-11-18 00:45:19 +00:00
export function 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-11-18 00:45:19 +00:00
}
2020-08-21 15:13:55 +00:00
2022-11-18 00:45:19 +00:00
export function 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-11-18 00:45:19 +00:00
}
2020-08-21 15:13:55 +00:00
2022-11-18 00:45:19 +00:00
export function 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-11-18 00:45:19 +00:00
}
2020-08-21 15:13:55 +00:00
2022-11-18 00:45:19 +00:00
export function 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-11-18 00:45:19 +00:00
}
2020-08-21 15:13:55 +00:00
2022-11-18 00:45:19 +00:00
export function Empty(): JSX.Element {
2020-08-21 15:13:55 +00:00
const props = createProps();
return <MediaGallery {...props} />;
2022-11-18 00:45:19 +00:00
}