2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-20 21:50:43 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
|
2021-12-03 01:05:32 +00:00
|
|
|
import type { AttachmentDraftType } from '../../types/Attachment';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Props } from './AttachmentList';
|
|
|
|
import { AttachmentList } from './AttachmentList';
|
2020-08-20 21:50:43 +00:00
|
|
|
import {
|
|
|
|
AUDIO_MP3,
|
|
|
|
IMAGE_GIF,
|
|
|
|
IMAGE_JPEG,
|
|
|
|
VIDEO_MP4,
|
2021-08-09 20:06:21 +00:00
|
|
|
stringToMIMEType,
|
2020-08-20 21:50:43 +00:00
|
|
|
} from '../../types/MIME';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../../util/setupI18n';
|
2020-08-20 21:50:43 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
2020-09-14 19:51:27 +00:00
|
|
|
|
2021-11-15 21:54:33 +00:00
|
|
|
import { fakeDraftAttachment } from '../../test-both/helpers/fakeAttachment';
|
2021-10-05 22:10:08 +00:00
|
|
|
|
2020-08-20 21:50:43 +00:00
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf('Components/Conversation/AttachmentList', module);
|
|
|
|
|
2021-12-03 01:05:32 +00:00
|
|
|
const createProps = (
|
|
|
|
overrideProps: Partial<Props<AttachmentDraftType>> = {}
|
|
|
|
): Props<AttachmentDraftType> => ({
|
2020-08-20 21:50:43 +00:00
|
|
|
attachments: overrideProps.attachments || [],
|
|
|
|
i18n,
|
|
|
|
onAddAttachment: action('onAddAttachment'),
|
|
|
|
onClickAttachment: action('onClickAttachment'),
|
|
|
|
onClose: action('onClose'),
|
|
|
|
onCloseAttachment: action('onCloseAttachment'),
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('One File', () => {
|
|
|
|
const props = createProps({
|
|
|
|
attachments: [
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: IMAGE_JPEG,
|
|
|
|
fileName: 'tina-rolf-269345-unsplash.jpg',
|
|
|
|
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2020-08-20 21:50:43 +00:00
|
|
|
],
|
|
|
|
});
|
2021-12-15 00:53:15 +00:00
|
|
|
return <AttachmentList {...props} />;
|
2020-08-20 21:50:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Multiple Visual Attachments', () => {
|
|
|
|
const props = createProps({
|
|
|
|
attachments: [
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: IMAGE_JPEG,
|
|
|
|
fileName: 'tina-rolf-269345-unsplash.jpg',
|
|
|
|
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: VIDEO_MP4,
|
|
|
|
fileName: 'pixabay-Soap-Bubble-7141.mp4',
|
2021-11-15 21:54:33 +00:00
|
|
|
url: '/fixtures/kitten-4-112-112.jpg',
|
|
|
|
screenshotPath: '/fixtures/kitten-4-112-112.jpg',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: IMAGE_GIF,
|
|
|
|
fileName: 'giphy-GVNv0UpeYm17e',
|
|
|
|
url: '/fixtures/giphy-GVNvOUpeYmI7e.gif',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2020-08-20 21:50:43 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AttachmentList {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Multiple with Non-Visual Types', () => {
|
|
|
|
const props = createProps({
|
|
|
|
attachments: [
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: IMAGE_JPEG,
|
|
|
|
fileName: 'tina-rolf-269345-unsplash.jpg',
|
|
|
|
url: '/fixtures/tina-rolf-269345-unsplash.jpg',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2021-08-09 20:06:21 +00:00
|
|
|
contentType: stringToMIMEType('text/plain'),
|
2020-08-20 21:50:43 +00:00
|
|
|
fileName: 'lorem-ipsum.txt',
|
|
|
|
url: '/fixtures/lorem-ipsum.txt',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: AUDIO_MP3,
|
|
|
|
fileName: 'incompetech-com-Agnus-Dei-X.mp3',
|
|
|
|
url: '/fixtures/incompetech-com-Agnus-Dei-X.mp3',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: VIDEO_MP4,
|
|
|
|
fileName: 'pixabay-Soap-Bubble-7141.mp4',
|
2021-11-15 21:54:33 +00:00
|
|
|
url: '/fixtures/kitten-4-112-112.jpg',
|
|
|
|
screenshotPath: '/fixtures/kitten-4-112-112.jpg',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2021-11-15 21:54:33 +00:00
|
|
|
fakeDraftAttachment({
|
2020-08-20 21:50:43 +00:00
|
|
|
contentType: IMAGE_GIF,
|
|
|
|
fileName: 'giphy-GVNv0UpeYm17e',
|
|
|
|
url: '/fixtures/giphy-GVNvOUpeYmI7e.gif',
|
2021-10-05 22:10:08 +00:00
|
|
|
}),
|
2020-08-20 21:50:43 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AttachmentList {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Empty List', () => {
|
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <AttachmentList {...props} />;
|
|
|
|
});
|