signal-desktop/ts/components/conversation/conversation-details/EditConversationAttributesModal.stories.tsx

69 lines
1.9 KiB
TypeScript
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ComponentProps } from 'react';
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../../util/setupI18n';
import enMessages from '../../../../_locales/en/messages.json';
2021-03-11 21:29:31 +00:00
import { EditConversationAttributesModal } from './EditConversationAttributesModal';
import { RequestState } from './util';
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/Conversation/ConversationDetails/EditConversationAttributesModal',
module
);
type PropsType = ComponentProps<typeof EditConversationAttributesModal>;
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
avatarPath: undefined,
2021-08-06 00:17:05 +00:00
conversationId: '123',
i18n,
initiallyFocusDescription: false,
onClose: action('onClose'),
makeRequest: action('onMakeRequest'),
requestState: RequestState.Inactive,
title: 'Bing Bong Group',
2021-08-06 00:17:05 +00:00
deleteAvatarFromDisk: action('deleteAvatarFromDisk'),
replaceAvatar: action('replaceAvatar'),
saveAvatarToDisk: action('saveAvatarToDisk'),
userAvatarData: [],
...overrideProps,
});
story.add('No avatar, empty title', () => (
<EditConversationAttributesModal {...createProps({ title: '' })} />
));
story.add('Avatar and title', () => (
<EditConversationAttributesModal
{...createProps({
avatarPath: '/fixtures/kitten-3-64-64.jpg',
})}
/>
));
story.add('Initially focusing description', () => (
<EditConversationAttributesModal
{...createProps({ title: 'Has title', initiallyFocusDescription: true })}
/>
));
story.add('Request active', () => (
<EditConversationAttributesModal
{...createProps({ requestState: RequestState.Active })}
/>
));
story.add('Has error', () => (
<EditConversationAttributesModal
{...createProps({ requestState: RequestState.InactiveWithError })}
/>
));