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
|
|
|
|
|
2020-08-26 18:40:23 +00:00
|
|
|
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';
|
2020-08-26 18:40:23 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Props } from './TypingBubble';
|
|
|
|
import { TypingBubble } from './TypingBubble';
|
2021-05-28 16:15:17 +00:00
|
|
|
import { AvatarColors } from '../../types/Colors';
|
2021-11-15 20:01:58 +00:00
|
|
|
import { getFakeBadge } from '../../test-both/helpers/getFakeBadge';
|
|
|
|
import { ThemeType } from '../../types/Util';
|
2020-08-26 18:40:23 +00:00
|
|
|
|
|
|
|
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,
|
2021-11-15 20:01:58 +00:00
|
|
|
badge: overrideProps.badge,
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe: false,
|
2020-08-26 18:40:23 +00:00
|
|
|
i18n,
|
|
|
|
color: select(
|
|
|
|
'color',
|
2021-05-28 16:15:17 +00:00
|
|
|
AvatarColors.reduce((m, c) => ({ ...m, [c]: c }), {}),
|
|
|
|
overrideProps.color || AvatarColors[0]
|
2020-08-26 18:40:23 +00:00
|
|
|
),
|
|
|
|
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: [],
|
2021-11-15 20:01:58 +00:00
|
|
|
theme: ThemeType.light,
|
2020-08-26 18:40:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Direct', () => {
|
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <TypingBubble {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Group', () => {
|
|
|
|
const props = createProps({ conversationType: 'group' });
|
|
|
|
|
|
|
|
return <TypingBubble {...props} />;
|
|
|
|
});
|
2021-11-15 20:01:58 +00:00
|
|
|
|
|
|
|
story.add('Group (with badge)', () => {
|
|
|
|
const props = createProps({
|
|
|
|
badge: getFakeBadge(),
|
|
|
|
conversationType: 'group',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <TypingBubble {...props} />;
|
|
|
|
});
|