signal-desktop/ts/components/StoryCreator.stories.tsx

108 lines
3 KiB
TypeScript
Raw Normal View History

2022-06-17 00:48:57 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Meta, Story } from '@storybook/react';
import React from 'react';
import type { PropsType } from './StoryCreator';
import enMessages from '../../_locales/en/messages.json';
import { StoryCreator } from './StoryCreator';
import { fakeAttachment } from '../test-both/helpers/fakeAttachment';
2022-08-10 18:37:19 +00:00
import {
getDefaultConversation,
getDefaultGroup,
} from '../test-both/helpers/getDefaultConversation';
2022-08-30 19:13:32 +00:00
import { getFakeDistributionListsWithMembers } from '../test-both/helpers/getFakeDistributionLists';
2022-06-17 00:48:57 +00:00
import { setupI18n } from '../util/setupI18n';
const i18n = setupI18n('en', enMessages);
export default {
title: 'Components/StoryCreator',
component: StoryCreator,
2022-08-02 19:31:55 +00:00
argTypes: {
2022-08-10 18:37:19 +00:00
candidateConversations: {
defaultValue: Array.from(Array(100), getDefaultConversation),
},
2022-08-02 19:31:55 +00:00
debouncedMaybeGrabLinkPreview: { action: true },
2022-08-30 19:13:32 +00:00
distributionLists: { defaultValue: getFakeDistributionListsWithMembers() },
2022-08-10 18:37:19 +00:00
getPreferredBadge: { action: true },
groupConversations: {
defaultValue: Array.from(Array(7), getDefaultGroup),
},
groupStories: {
defaultValue: Array.from(Array(4), getDefaultGroup),
2022-08-02 19:31:55 +00:00
},
2022-08-23 17:24:55 +00:00
hasFirstStoryPostExperience: {
defaultValue: false,
},
2022-08-02 19:31:55 +00:00
i18n: { defaultValue: i18n },
2022-11-16 21:41:38 +00:00
imageToBlurHash: async () => 'LDA,FDBnm+I=p{tkIUI;~UkpELV]',
2022-08-04 19:23:24 +00:00
installedPacks: {
defaultValue: [],
},
isSending: {
defaultValue: false,
},
2022-08-10 18:37:19 +00:00
linkPreview: {
defaultValue: undefined,
},
2022-08-02 19:31:55 +00:00
me: {
defaultValue: getDefaultConversation(),
},
onClose: { action: true },
2022-08-30 19:13:32 +00:00
onDeleteList: { action: true },
2022-08-10 18:37:19 +00:00
onDistributionListCreated: { action: true },
2022-08-23 17:24:55 +00:00
onHideMyStoriesFrom: { action: true },
2022-08-02 19:31:55 +00:00
onSend: { action: true },
2022-08-23 17:24:55 +00:00
onViewersUpdated: { action: true },
2022-08-04 19:23:24 +00:00
processAttachment: { action: true },
recentStickers: {
defaultValue: [],
},
2022-09-21 14:48:04 +00:00
sendStoryModalOpenStateChanged: { action: true },
2022-08-23 17:24:55 +00:00
setMyStoriesToAllSignalConnections: { action: true },
2022-08-02 19:31:55 +00:00
signalConnections: {
defaultValue: Array.from(Array(42), getDefaultConversation),
},
2022-08-23 17:24:55 +00:00
toggleSignalConnectionsModal: { action: true },
2022-08-02 19:31:55 +00:00
},
2022-06-17 00:48:57 +00:00
} as Meta;
2022-11-18 00:45:19 +00:00
// eslint-disable-next-line react/function-component-definition
2022-06-17 00:48:57 +00:00
const Template: Story<PropsType> = args => <StoryCreator {...args} />;
export const Default = Template.bind({});
2022-08-02 19:31:55 +00:00
Default.args = {};
2022-06-17 00:48:57 +00:00
Default.story = {
name: 'w/o Link Preview available',
};
export const LinkPreview = Template.bind({});
LinkPreview.args = {
linkPreview: {
domain: 'www.catsandkittens.lolcats',
image: fakeAttachment({
url: '/fixtures/kitten-4-112-112.jpg',
}),
title: 'Cats & Kittens LOL',
url: 'https://www.catsandkittens.lolcats/kittens/page/1',
},
};
LinkPreview.story = {
name: 'with Link Preview ready to be applied',
};
2022-08-23 17:24:55 +00:00
export const FirstTime = Template.bind({});
FirstTime.args = {
hasFirstStoryPostExperience: true,
};
FirstTime.story = {
name: 'First time posting a story',
};
export const Sending = Template.bind({});
Sending.args = {
isSending: true,
};