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

165 lines
4.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
2020-06-04 18:16:19 +00:00
import * as React from 'react';
2020-09-12 00:46:52 +00:00
import { action } from '@storybook/addon-actions';
2020-06-04 18:16:19 +00:00
import { IncomingCallBar } from './IncomingCallBar';
2021-08-20 16:06:15 +00:00
import { CallMode } from '../types/Calling';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
2020-06-04 18:16:19 +00:00
import enMessages from '../../_locales/en/messages.json';
2021-05-07 22:21:10 +00:00
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
2020-06-04 18:16:19 +00:00
const i18n = setupI18n('en', enMessages);
2021-08-20 16:06:15 +00:00
const commonProps = {
2020-06-04 18:16:19 +00:00
acceptCall: action('accept-call'),
2021-08-20 16:06:15 +00:00
bounceAppIconStart: action('bounceAppIconStart'),
bounceAppIconStop: action('bounceAppIconStop'),
call: {
conversationId: 'fake-conversation-id',
2020-06-04 18:16:19 +00:00
callId: 0,
isIncoming: true,
isVideoCall: true,
},
2021-05-07 22:21:10 +00:00
conversation: getDefaultConversation({
2020-10-08 01:25:33 +00:00
id: '3051234567',
2020-07-24 01:35:32 +00:00
avatarPath: undefined,
2020-06-04 18:16:19 +00:00
name: 'Rick Sanchez',
phoneNumber: '3051234567',
profileName: 'Rick Sanchez',
2020-07-24 01:35:32 +00:00
title: 'Rick Sanchez',
2021-05-07 22:21:10 +00:00
}),
2020-06-04 18:16:19 +00:00
declineCall: action('decline-call'),
i18n,
2021-08-20 16:06:15 +00:00
notifyForCall: action('notify-for-call'),
2020-06-04 18:16:19 +00:00
};
2021-08-20 16:06:15 +00:00
const directConversation = getDefaultConversation({
id: '3051234567',
avatarPath: undefined,
name: 'Rick Sanchez',
phoneNumber: '3051234567',
profileName: 'Rick Sanchez',
title: 'Rick Sanchez',
});
const groupConversation = getDefaultConversation({
avatarPath: undefined,
name: 'Tahoe Trip',
title: 'Tahoe Trip',
type: 'group',
});
2020-06-04 18:16:19 +00:00
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/IncomingCallBar',
};
export const IncomingDirectCallVideo = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={directConversation}
callMode={CallMode.Direct}
isVideoCall
/>
);
IncomingDirectCallVideo.story = {
name: 'Incoming direct call (video)',
};
export const IncomingDirectCallAudio = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={directConversation}
callMode={CallMode.Direct}
isVideoCall={false}
/>
);
IncomingDirectCallAudio.story = {
name: 'Incoming direct call (audio)',
};
export const IncomingGroupCallOnlyCallingYou = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={groupConversation}
callMode={CallMode.Group}
otherMembersRung={[]}
ringer={{ firstName: 'Rick', title: 'Rick Sanchez' }}
/>
);
IncomingGroupCallOnlyCallingYou.story = {
name: 'Incoming group call (only calling you)',
};
export const IncomingGroupCallCallingYouAnd1Other = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={groupConversation}
callMode={CallMode.Group}
otherMembersRung={[{ firstName: 'Morty', title: 'Morty Smith' }]}
ringer={{ firstName: 'Rick', title: 'Rick Sanchez' }}
/>
);
IncomingGroupCallCallingYouAnd1Other.story = {
name: 'Incoming group call (calling you and 1 other)',
};
export const IncomingGroupCallCallingYouAnd2Others = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={groupConversation}
callMode={CallMode.Group}
otherMembersRung={[
{ firstName: 'Morty', title: 'Morty Smith' },
{ firstName: 'Summer', title: 'Summer Smith' },
]}
ringer={{ firstName: 'Rick', title: 'Rick Sanchez' }}
/>
);
IncomingGroupCallCallingYouAnd2Others.story = {
name: 'Incoming group call (calling you and 2 others)',
};
export const IncomingGroupCallCallingYouAnd3Others = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={groupConversation}
callMode={CallMode.Group}
otherMembersRung={[
{ firstName: 'Morty', title: 'Morty Smith' },
{ firstName: 'Summer', title: 'Summer Smith' },
{ firstName: 'Beth', title: 'Beth Smith' },
]}
ringer={{ firstName: 'Rick', title: 'Rick Sanchez' }}
/>
);
IncomingGroupCallCallingYouAnd3Others.story = {
name: 'Incoming group call (calling you and 3 others)',
};
export const IncomingGroupCallCallingYouAnd4Others = (): JSX.Element => (
<IncomingCallBar
{...commonProps}
conversation={groupConversation}
callMode={CallMode.Group}
otherMembersRung={[
{ firstName: 'Morty', title: 'Morty Smith' },
{ firstName: 'Summer', title: 'Summer Smith' },
{ firstName: 'Beth', title: 'Beth Sanchez' },
{ firstName: 'Jerry', title: 'Beth Smith' },
]}
ringer={{ firstName: 'Rick', title: 'Rick Sanchez' }}
/>
);
IncomingGroupCallCallingYouAnd4Others.story = {
name: 'Incoming group call (calling you and 4 others)',
};