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

303 lines
8 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-10-30 17:52:21 +00:00
import React, { ComponentProps } from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { setup as setupI18n } from '../../../js/modules/i18n';
2020-09-14 19:51:27 +00:00
import enMessages from '../../../_locales/en/messages.json';
import {
ConversationHeader,
OutgoingCallButtonStyle,
} from './ConversationHeader';
2020-04-06 16:48:58 +00:00
import { gifUrl } from '../../storybook/Fixtures';
const book = storiesOf('Components/Conversation/ConversationHeader', module);
const i18n = setupI18n('en', enMessages);
type ConversationHeaderStory = {
title: string;
description: string;
items: Array<{
title: string;
2020-10-30 17:52:21 +00:00
props: ComponentProps<typeof ConversationHeader>;
}>;
};
2020-10-30 17:52:21 +00:00
const commonProps = {
showBackButton: false,
outgoingCallButtonStyle: OutgoingCallButtonStyle.Both,
2020-10-30 17:52:21 +00:00
markedUnread: false,
i18n,
onShowConversationDetails: action('onShowConversationDetails'),
onSetDisappearingMessages: action('onSetDisappearingMessages'),
onDeleteMessages: action('onDeleteMessages'),
onResetSession: action('onResetSession'),
onSearchInConversation: action('onSearchInConversation'),
2020-08-27 19:45:08 +00:00
onSetMuteNotifications: action('onSetMuteNotifications'),
2020-06-04 18:16:19 +00:00
onOutgoingAudioCallInConversation: action(
'onOutgoingAudioCallInConversation'
),
onOutgoingVideoCallInConversation: action(
'onOutgoingVideoCallInConversation'
),
onShowSafetyNumber: action('onShowSafetyNumber'),
onShowAllMedia: action('onShowAllMedia'),
2021-01-28 00:18:50 +00:00
onShowContactModal: action('onShowContactModal'),
onShowGroupMembers: action('onShowGroupMembers'),
onGoBack: action('onGoBack'),
onArchive: action('onArchive'),
onMarkUnread: action('onMarkUnread'),
onMoveToInbox: action('onMoveToInbox'),
2020-10-02 18:30:43 +00:00
onSetPin: action('onSetPin'),
};
const stories: Array<ConversationHeaderStory> = [
{
title: '1:1 conversation',
description:
"Note the five items in menu, and the second-level menu with disappearing messages options. Disappearing message set to 'off'.",
items: [
{
title: 'With name and profile, verified',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'red',
isVerified: true,
2020-04-06 16:48:58 +00:00
avatarPath: gifUrl,
2020-07-24 01:35:32 +00:00
title: 'Someone 🔥 Somewhere',
name: 'Someone 🔥 Somewhere',
phoneNumber: '(202) 555-0001',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '1',
profileName: '🔥Flames🔥',
acceptedMessageRequest: true,
},
},
{
title: 'With name, not verified, no avatar',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'blue',
isVerified: false,
2020-07-24 01:35:32 +00:00
title: 'Someone 🔥 Somewhere',
name: 'Someone 🔥 Somewhere',
phoneNumber: '(202) 555-0002',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '2',
acceptedMessageRequest: true,
2020-07-24 01:35:32 +00:00
},
},
{
title: 'With name, not verified, descenders',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2020-07-24 01:35:32 +00:00
color: 'blue',
isVerified: false,
title: 'Joyrey 🔥 Leppey',
name: 'Joyrey 🔥 Leppey',
phoneNumber: '(202) 555-0002',
type: 'direct',
id: '2',
acceptedMessageRequest: true,
},
},
{
title: 'Profile, no name',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'teal',
isVerified: false,
phoneNumber: '(202) 555-0003',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '3',
2020-07-24 01:35:32 +00:00
title: '🔥Flames🔥',
profileName: '🔥Flames🔥',
acceptedMessageRequest: true,
},
},
{
title: 'No name, no profile, no color',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2020-07-24 01:35:32 +00:00
title: '(202) 555-0011',
phoneNumber: '(202) 555-0011',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '11',
acceptedMessageRequest: true,
},
},
{
title: 'With back button',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
showBackButton: true,
color: 'deep_orange',
phoneNumber: '(202) 555-0004',
2020-07-24 01:35:32 +00:00
title: '(202) 555-0004',
type: 'direct',
id: '4',
acceptedMessageRequest: true,
},
},
{
title: 'Disappearing messages set',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'indigo',
2020-07-24 01:35:32 +00:00
title: '(202) 555-0005',
phoneNumber: '(202) 555-0005',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '5',
2020-10-30 17:52:21 +00:00
expireTimer: 10,
acceptedMessageRequest: true,
},
},
2021-03-01 20:08:37 +00:00
{
title: 'Disappearing messages + verified',
props: {
...commonProps,
color: 'indigo',
title: '(202) 555-0005',
phoneNumber: '(202) 555-0005',
type: 'direct',
id: '5',
expireTimer: 60,
acceptedMessageRequest: true,
isVerified: true,
},
},
2020-08-27 19:45:08 +00:00
{
title: 'Muting Conversation',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2020-08-27 19:45:08 +00:00
color: 'ultramarine',
title: '(202) 555-0006',
phoneNumber: '(202) 555-0006',
type: 'direct',
id: '6',
acceptedMessageRequest: true,
2020-10-30 17:52:21 +00:00
muteExpiresAt: new Date('3000-10-18T11:11:11Z').valueOf(),
2020-08-27 19:45:08 +00:00
},
},
],
},
{
title: 'In a group',
description:
"Note that the menu should includes 'Show Members' instead of 'Show Safety Number'",
items: [
{
title: 'Basic',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'signal-blue',
2020-07-24 01:35:32 +00:00
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
id: '1',
2020-07-24 01:35:32 +00:00
type: 'group',
2020-10-30 17:52:21 +00:00
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
},
},
{
title: 'In a group you left - no disappearing messages',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'signal-blue',
2020-07-24 01:35:32 +00:00
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
id: '2',
2020-07-24 01:35:32 +00:00
type: 'group',
2020-10-30 17:52:21 +00:00
left: true,
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
},
},
2020-11-20 17:19:28 +00:00
{
title: 'In a group with an active group call',
props: {
...commonProps,
color: 'signal-blue',
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
id: '1',
type: 'group',
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.Join,
},
},
],
},
{
title: 'Note to Self',
description: 'No safety number entry.',
items: [
{
title: 'In chat with yourself',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
color: 'blue',
2020-07-24 01:35:32 +00:00
title: '(202) 555-0007',
phoneNumber: '(202) 555-0007',
id: '7',
2020-07-24 01:35:32 +00:00
type: 'direct',
isMe: true,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
2020-05-27 21:37:06 +00:00
},
},
],
},
{
title: 'Unaccepted',
description: 'No safety number entry.',
items: [
{
title: '1:1 conversation',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2020-05-27 21:37:06 +00:00
color: 'blue',
2020-07-24 01:35:32 +00:00
title: '(202) 555-0007',
2020-05-27 21:37:06 +00:00
phoneNumber: '(202) 555-0007',
id: '7',
2020-07-24 01:35:32 +00:00
type: 'direct',
2020-05-27 21:37:06 +00:00
isMe: false,
acceptedMessageRequest: false,
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
},
},
],
},
];
stories.forEach(({ title, description, items }) =>
book.add(
title,
() =>
items.map(({ title: subtitle, props }, i) => {
return (
<div key={i}>
{subtitle ? <h3>{subtitle}</h3> : null}
<ConversationHeader {...props} />
</div>
);
}),
{
docs: description,
}
)
);