2021-05-27 20:17:05 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-17 18:53:09 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
2020-09-12 00:46:52 +00:00
|
|
|
import { boolean } from '@storybook/addon-knobs';
|
2020-08-17 18:53:09 +00:00
|
|
|
|
2021-07-07 17:05:03 +00:00
|
|
|
import { IMAGE_JPEG } from '../types/MIME';
|
2020-08-17 18:53:09 +00:00
|
|
|
import { CompositionArea, Props } from './CompositionArea';
|
|
|
|
import { setup as setupI18n } from '../../js/modules/i18n';
|
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf('Components/CompositionArea', module);
|
|
|
|
|
|
|
|
// necessary for the add attachment button to render properly
|
|
|
|
story.addDecorator(storyFn => <div className="file-input">{storyFn()}</div>);
|
|
|
|
|
|
|
|
// necessary for the mic button to render properly
|
|
|
|
const micCellEl = new DOMParser().parseFromString(
|
|
|
|
`
|
|
|
|
<div class="capture-audio">
|
|
|
|
<button class="microphone"></button>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
'text/html'
|
|
|
|
).body.firstElementChild as HTMLElement;
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
|
|
|
i18n,
|
|
|
|
micCellEl,
|
|
|
|
onChooseAttachment: action('onChooseAttachment'),
|
2021-06-25 16:08:16 +00:00
|
|
|
// AttachmentList
|
2021-07-07 17:05:03 +00:00
|
|
|
draftAttachments: overrideProps.draftAttachments || [],
|
2021-06-25 16:08:16 +00:00
|
|
|
onAddAttachment: action('onAddAttachment'),
|
|
|
|
onClearAttachments: action('onClearAttachments'),
|
|
|
|
onClickAttachment: action('onClickAttachment'),
|
|
|
|
onCloseAttachment: action('onCloseAttachment'),
|
|
|
|
// StagedLinkPreview
|
|
|
|
linkPreviewLoading: Boolean(overrideProps.linkPreviewLoading),
|
|
|
|
linkPreviewResult: overrideProps.linkPreviewResult,
|
|
|
|
onCloseLinkPreview: action('onCloseLinkPreview'),
|
|
|
|
// Quote
|
|
|
|
quotedMessageProps: overrideProps.quotedMessageProps,
|
|
|
|
onClickQuotedMessage: action('onClickQuotedMessage'),
|
|
|
|
setQuotedMessage: action('setQuotedMessage'),
|
|
|
|
// MediaQualitySelector
|
|
|
|
onSelectMediaQuality: action('onSelectMediaQuality'),
|
|
|
|
shouldSendHighQualityAttachments: Boolean(
|
|
|
|
overrideProps.shouldSendHighQualityAttachments
|
|
|
|
),
|
2020-08-17 18:53:09 +00:00
|
|
|
// CompositionInput
|
|
|
|
onSubmit: action('onSubmit'),
|
|
|
|
onEditorStateChange: action('onEditorStateChange'),
|
|
|
|
onTextTooLong: action('onTextTooLong'),
|
2020-11-03 01:19:52 +00:00
|
|
|
draftText: overrideProps.draftText || undefined,
|
2020-08-17 18:53:09 +00:00
|
|
|
clearQuotedMessage: action('clearQuotedMessage'),
|
|
|
|
getQuotedMessage: action('getQuotedMessage'),
|
2021-01-29 21:19:24 +00:00
|
|
|
sortedGroupMembers: [],
|
2020-08-17 18:53:09 +00:00
|
|
|
// EmojiButton
|
|
|
|
onPickEmoji: action('onPickEmoji'),
|
|
|
|
onSetSkinTone: action('onSetSkinTone'),
|
|
|
|
recentEmojis: [],
|
|
|
|
skinTone: 1,
|
|
|
|
// StickerButton
|
|
|
|
knownPacks: overrideProps.knownPacks || [],
|
|
|
|
receivedPacks: [],
|
|
|
|
installedPacks: [],
|
|
|
|
blessedPacks: [],
|
|
|
|
recentStickers: [],
|
|
|
|
clearInstalledStickerPack: action('clearInstalledStickerPack'),
|
|
|
|
onClickAddPack: action('onClickAddPack'),
|
|
|
|
onPickSticker: action('onPickSticker'),
|
|
|
|
clearShowIntroduction: action('clearShowIntroduction'),
|
|
|
|
showPickerHint: false,
|
|
|
|
clearShowPickerHint: action('clearShowPickerHint'),
|
|
|
|
// Message Requests
|
|
|
|
conversationType: 'direct',
|
|
|
|
onAccept: action('onAccept'),
|
|
|
|
onBlock: action('onBlock'),
|
2021-05-27 20:17:05 +00:00
|
|
|
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
2020-08-17 18:53:09 +00:00
|
|
|
onDelete: action('onDelete'),
|
|
|
|
onUnblock: action('onUnblock'),
|
|
|
|
messageRequestsEnabled: boolean(
|
|
|
|
'messageRequestsEnabled',
|
|
|
|
overrideProps.messageRequestsEnabled || false
|
|
|
|
),
|
|
|
|
title: '',
|
2020-12-01 16:42:35 +00:00
|
|
|
// GroupV1 Disabled Actions
|
|
|
|
onStartGroupMigration: action('onStartGroupMigration'),
|
2021-07-20 20:18:35 +00:00
|
|
|
// GroupV2
|
|
|
|
announcementsOnly: boolean(
|
|
|
|
'announcementsOnly',
|
|
|
|
Boolean(overrideProps.announcementsOnly)
|
|
|
|
),
|
|
|
|
areWeAdmin: boolean('areWeAdmin', Boolean(overrideProps.areWeAdmin)),
|
|
|
|
groupAdmins: [],
|
|
|
|
openConversation: action('openConversation'),
|
2021-01-29 22:16:48 +00:00
|
|
|
onCancelJoinRequest: action('onCancelJoinRequest'),
|
2021-05-13 20:57:27 +00:00
|
|
|
// SMS-only
|
|
|
|
isSMSOnly: overrideProps.isSMSOnly || false,
|
|
|
|
isFetchingUUID: overrideProps.isFetchingUUID || false,
|
2020-08-17 18:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Default', () => {
|
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Starting Text', () => {
|
|
|
|
const props = createProps({
|
2020-11-03 01:19:52 +00:00
|
|
|
draftText: "here's some starting text",
|
2020-08-17 18:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Sticker Button', () => {
|
|
|
|
const props = createProps({
|
2020-09-12 00:46:52 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2020-08-17 18:53:09 +00:00
|
|
|
knownPacks: [{} as any],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Message Request', () => {
|
|
|
|
const props = createProps({
|
|
|
|
messageRequestsEnabled: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
2021-05-13 20:57:27 +00:00
|
|
|
|
|
|
|
story.add('SMS-only fetching UUID', () => {
|
|
|
|
const props = createProps({
|
|
|
|
isSMSOnly: true,
|
|
|
|
isFetchingUUID: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('SMS-only', () => {
|
|
|
|
const props = createProps({
|
|
|
|
isSMSOnly: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
2021-07-07 17:05:03 +00:00
|
|
|
|
|
|
|
story.add('Attachments', () => {
|
|
|
|
const props = createProps({
|
|
|
|
draftAttachments: [
|
|
|
|
{
|
|
|
|
contentType: IMAGE_JPEG,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
return <CompositionArea {...props} />;
|
|
|
|
});
|
2021-07-20 20:18:35 +00:00
|
|
|
|
|
|
|
story.add('Announcements Only group', () => (
|
|
|
|
<CompositionArea
|
|
|
|
{...createProps({
|
|
|
|
announcementsOnly: true,
|
|
|
|
areWeAdmin: false,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|