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

85 lines
2.2 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-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, text } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
2020-06-04 18:16:19 +00:00
import { IncomingCallBar } from './IncomingCallBar';
import { Colors, ColorType } from '../types/Colors';
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 defaultProps = {
acceptCall: action('accept-call'),
call: {
conversationId: 'fake-conversation-id',
2020-06-04 18:16:19 +00:00
callId: 0,
isIncoming: true,
isVideoCall: true,
},
conversation: {
2020-10-08 01:25:33 +00:00
id: '3051234567',
2020-07-24 01:35:32 +00:00
avatarPath: undefined,
contactColor: 'ultramarine' as ColorType,
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',
2020-06-04 18:16:19 +00:00
},
declineCall: action('decline-call'),
i18n,
};
const permutations = [
{
title: 'Incoming Call Bar (video)',
props: {},
2020-06-04 18:16:19 +00:00
},
{
title: 'Incoming Call Bar (audio)',
props: {
call: {
...defaultProps.call,
2020-06-04 18:16:19 +00:00
isVideoCall: false,
},
},
},
];
storiesOf('Components/IncomingCallBar', module)
.add('Knobs Playground', () => {
const color = select('color', Colors, 'ultramarine');
2020-06-04 18:16:19 +00:00
const isVideoCall = boolean('isVideoCall', false);
const name = text(
'name',
'Rick Sanchez Foo Bar Baz Spool Cool Mango Fango Wand Mars Venus Jupiter Spark Mirage Water Loop Branch Zeus Element Sail Bananas Cars Horticulture Turtle Lion Zebra Micro Music Garage Iguana Ohio Retro Joy Entertainment Logo Understanding Diary'
);
return (
<IncomingCallBar
{...defaultProps}
call={{
...defaultProps.call,
2020-06-04 18:16:19 +00:00
isVideoCall,
}}
conversation={{
...defaultProps.conversation,
color,
2020-06-04 18:16:19 +00:00
name,
}}
/>
);
})
.add('Iterations', () => {
return permutations.map(({ props, title }) => (
<>
<h3>{title}</h3>
<IncomingCallBar {...defaultProps} {...props} />
</>
));
});