signal-desktop/ts/components/conversation/TypingBubble.stories.tsx

49 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { select, text } from '@storybook/addon-knobs';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
import type { Props } from './TypingBubble';
import { TypingBubble } from './TypingBubble';
2021-05-28 16:15:17 +00:00
import { AvatarColors } from '../../types/Colors';
const i18n = setupI18n('en', enMessages);
const story = storiesOf('Components/Conversation/TypingBubble', module);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
2021-05-07 22:21:10 +00:00
acceptedMessageRequest: true,
isMe: false,
i18n,
color: select(
'color',
2021-05-28 16:15:17 +00:00
AvatarColors.reduce((m, c) => ({ ...m, [c]: c }), {}),
overrideProps.color || AvatarColors[0]
),
avatarPath: text('avatarPath', overrideProps.avatarPath || ''),
title: '',
profileName: text('profileName', overrideProps.profileName || ''),
conversationType: select(
'conversationType',
{ group: 'group', direct: 'direct' },
overrideProps.conversationType || 'direct'
),
2021-05-07 22:21:10 +00:00
sharedGroupNames: [],
});
story.add('Direct', () => {
const props = createProps();
return <TypingBubble {...props} />;
});
story.add('Group', () => {
const props = createProps({ conversationType: 'group' });
return <TypingBubble {...props} />;
});