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

85 lines
2.4 KiB
TypeScript
Raw Normal View History

2020-06-04 18:16:19 +00:00
import * as React from 'react';
2020-09-12 00:46:52 +00:00
import { storiesOf } from '@storybook/react';
import { boolean, select } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
2020-06-04 18:16:19 +00:00
import { CallState } from '../types/Calling';
import { ColorType } from '../types/Colors';
2020-10-08 01:25:33 +00:00
import { CallScreen, PropsType } from './CallScreen';
2020-06-04 18:16:19 +00:00
import { setup as setupI18n } from '../../js/modules/i18n';
import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
const callDetails = {
acceptedTime: Date.now(),
2020-06-04 18:16:19 +00:00
callId: 0,
isIncoming: true,
isVideoCall: true,
2020-07-24 01:35:32 +00:00
2020-10-08 01:25:33 +00:00
id: '3051234567',
2020-07-24 01:35:32 +00:00
avatarPath: undefined,
color: 'ultramarine' as ColorType,
title: 'Rick Sanchez',
2020-06-04 18:16:19 +00:00
name: 'Rick Sanchez',
phoneNumber: '3051234567',
profileName: 'Rick Sanchez',
};
2020-10-08 01:25:33 +00:00
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
2020-06-04 18:16:19 +00:00
callDetails,
2020-10-08 01:25:33 +00:00
callState: select(
'callState',
CallState,
overrideProps.callState || CallState.Accepted
),
2020-06-04 18:16:19 +00:00
hangUp: action('hang-up'),
2020-10-08 01:25:33 +00:00
hasLocalAudio: boolean('hasLocalAudio', overrideProps.hasLocalAudio || false),
hasLocalVideo: boolean('hasLocalVideo', overrideProps.hasLocalVideo || false),
hasRemoteVideo: boolean(
'hasRemoteVideo',
overrideProps.hasRemoteVideo || false
),
2020-06-04 18:16:19 +00:00
i18n,
setLocalAudio: action('set-local-audio'),
2020-08-27 00:03:42 +00:00
setLocalPreview: action('set-local-preview'),
2020-06-04 18:16:19 +00:00
setLocalVideo: action('set-local-video'),
2020-08-27 00:03:42 +00:00
setRendererCanvas: action('set-renderer-canvas'),
2020-10-01 00:43:05 +00:00
togglePip: action('toggle-pip'),
2020-08-27 00:03:42 +00:00
toggleSettings: action('toggle-settings'),
2020-10-08 01:25:33 +00:00
});
const story = storiesOf('Components/CallScreen', module);
story.add('Default', () => {
return <CallScreen {...createProps()} />;
});
story.add('Pre-Ring', () => {
return <CallScreen {...createProps({ callState: CallState.Prering })} />;
});
story.add('Ringing', () => {
return <CallScreen {...createProps({ callState: CallState.Ringing })} />;
});
story.add('Reconnecting', () => {
return <CallScreen {...createProps({ callState: CallState.Reconnecting })} />;
});
story.add('Ended', () => {
return <CallScreen {...createProps({ callState: CallState.Ended })} />;
});
2020-06-04 18:16:19 +00:00
2020-10-08 01:25:33 +00:00
story.add('hasLocalAudio', () => {
return <CallScreen {...createProps({ hasLocalAudio: true })} />;
});
2020-06-04 18:16:19 +00:00
2020-10-08 01:25:33 +00:00
story.add('hasLocalVideo', () => {
return <CallScreen {...createProps({ hasLocalVideo: true })} />;
});
2020-06-04 18:16:19 +00:00
2020-10-08 01:25:33 +00:00
story.add('hasRemoteVideo', () => {
return <CallScreen {...createProps({ hasRemoteVideo: true })} />;
});