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

106 lines
2.7 KiB
TypeScript
Raw Normal View History

// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-10-08 01:25:33 +00:00
import * as React from 'react';
import { storiesOf } from '@storybook/react';
2020-11-19 18:11:35 +00:00
import { select } from '@storybook/addon-knobs';
2020-10-08 01:25:33 +00:00
import { action } from '@storybook/addon-actions';
2020-11-19 18:11:35 +00:00
import { CallingButton, CallingButtonType, PropsType } from './CallingButton';
import { TooltipPlacement } from './Tooltip';
2020-10-08 01:25:33 +00:00
import { setup as setupI18n } from '../../js/modules/i18n';
import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
buttonType:
overrideProps.buttonType ||
select('buttonType', CallingButtonType, CallingButtonType.HANG_UP),
2020-10-08 01:25:33 +00:00
i18n,
onClick: action('on-click'),
tooltipDirection: select(
'tooltipDirection',
2020-11-19 18:11:35 +00:00
TooltipPlacement,
overrideProps.tooltipDirection || TooltipPlacement.Bottom
2020-10-08 01:25:33 +00:00
),
});
const story = storiesOf('Components/CallingButton', module);
story.add('Kitchen Sink', () => {
return (
<>
{Object.keys(CallingButtonType).map(buttonType => (
<CallingButton
key={buttonType}
{...createProps({ buttonType: buttonType as CallingButtonType })}
/>
))}
</>
);
2020-10-08 01:25:33 +00:00
});
story.add('Audio On', () => {
const props = createProps({
buttonType: CallingButtonType.AUDIO_ON,
});
return <CallingButton {...props} />;
});
story.add('Audio Off', () => {
const props = createProps({
buttonType: CallingButtonType.AUDIO_OFF,
});
return <CallingButton {...props} />;
});
story.add('Audio Disabled', () => {
const props = createProps({
buttonType: CallingButtonType.AUDIO_DISABLED,
});
return <CallingButton {...props} />;
});
2020-10-08 01:25:33 +00:00
story.add('Video On', () => {
const props = createProps({
buttonType: CallingButtonType.VIDEO_ON,
});
return <CallingButton {...props} />;
});
story.add('Video Off', () => {
const props = createProps({
buttonType: CallingButtonType.VIDEO_OFF,
});
return <CallingButton {...props} />;
});
story.add('Video Disabled', () => {
const props = createProps({
buttonType: CallingButtonType.VIDEO_DISABLED,
});
return <CallingButton {...props} />;
});
2020-10-08 01:25:33 +00:00
story.add('Tooltip right', () => {
const props = createProps({
2020-11-19 18:11:35 +00:00
tooltipDirection: TooltipPlacement.Right,
2020-10-08 01:25:33 +00:00
});
return <CallingButton {...props} />;
});
story.add('Presenting On', () => {
const props = createProps({
buttonType: CallingButtonType.PRESENTING_ON,
});
return <CallingButton {...props} />;
});
story.add('Presenting Off', () => {
const props = createProps({
buttonType: CallingButtonType.PRESENTING_OFF,
});
return <CallingButton {...props} />;
});