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';
|
2020-08-13 20:53:45 +00:00
|
|
|
import { ColorType } from '../types/Colors';
|
2020-06-04 18:16:19 +00:00
|
|
|
import { CallScreen } from './CallScreen';
|
|
|
|
import { setup as setupI18n } from '../../js/modules/i18n';
|
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const callDetails = {
|
|
|
|
callId: 0,
|
|
|
|
isIncoming: true,
|
|
|
|
isVideoCall: true,
|
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',
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
callDetails,
|
|
|
|
callState: CallState.Accepted,
|
|
|
|
hangUp: action('hang-up'),
|
|
|
|
hasLocalAudio: true,
|
|
|
|
hasLocalVideo: true,
|
|
|
|
hasRemoteVideo: true,
|
|
|
|
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-06-04 18:16:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const permutations = [
|
|
|
|
{
|
|
|
|
title: 'Call Screen',
|
|
|
|
props: {},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Call Screen (Pre-ring)',
|
|
|
|
props: {
|
|
|
|
callState: CallState.Prering,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Call Screen (Ringing)',
|
|
|
|
props: {
|
|
|
|
callState: CallState.Ringing,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Call Screen (Reconnecting)',
|
|
|
|
props: {
|
|
|
|
callState: CallState.Reconnecting,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Call Screen (Ended)',
|
|
|
|
props: {
|
|
|
|
callState: CallState.Ended,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Calling (no local audio)',
|
|
|
|
props: {
|
|
|
|
...defaultProps,
|
|
|
|
hasLocalAudio: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Calling (no local video)',
|
|
|
|
props: {
|
|
|
|
...defaultProps,
|
|
|
|
hasLocalVideo: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Calling (no remote video)',
|
|
|
|
props: {
|
|
|
|
...defaultProps,
|
|
|
|
hasRemoteVideo: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
storiesOf('Components/CallScreen', module)
|
|
|
|
.add('Knobs Playground', () => {
|
|
|
|
const callState = select('callState', CallState, CallState.Accepted);
|
|
|
|
const hasLocalAudio = boolean('hasLocalAudio', true);
|
|
|
|
const hasLocalVideo = boolean('hasLocalVideo', true);
|
|
|
|
const hasRemoteVideo = boolean('hasRemoteVideo', true);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CallScreen
|
|
|
|
{...defaultProps}
|
|
|
|
callState={callState}
|
|
|
|
hasLocalAudio={hasLocalAudio}
|
|
|
|
hasLocalVideo={hasLocalVideo}
|
|
|
|
hasRemoteVideo={hasRemoteVideo}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.add('Iterations', () => {
|
|
|
|
return permutations.map(({ props, title }) => (
|
|
|
|
<>
|
|
|
|
<h3>{title}</h3>
|
|
|
|
<CallScreen {...defaultProps} {...props} />
|
|
|
|
</>
|
|
|
|
));
|
|
|
|
});
|