2021-05-20 21:54:03 +00:00
|
|
|
// 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';
|
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';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './CallingButton';
|
|
|
|
import { CallingButton, CallingButtonType } from './CallingButton';
|
2020-11-19 18:11:35 +00:00
|
|
|
import { TooltipPlacement } from './Tooltip';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2020-10-08 01:25:33 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
2021-05-20 21:54:03 +00:00
|
|
|
buttonType:
|
|
|
|
overrideProps.buttonType ||
|
|
|
|
select('buttonType', CallingButtonType, CallingButtonType.HANG_UP),
|
2020-10-08 01:25:33 +00:00
|
|
|
i18n,
|
|
|
|
onClick: action('on-click'),
|
2021-09-18 00:20:29 +00:00
|
|
|
onMouseEnter: action('on-mouse-enter'),
|
|
|
|
onMouseLeave: action('on-mouse-leave'),
|
2020-10-08 01:25:33 +00:00
|
|
|
tooltipDirection: select(
|
|
|
|
'tooltipDirection',
|
2020-11-19 18:11:35 +00:00
|
|
|
TooltipPlacement,
|
|
|
|
overrideProps.tooltipDirection || TooltipPlacement.Bottom
|
2020-10-08 01:25:33 +00:00
|
|
|
),
|
|
|
|
});
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/CallingButton',
|
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const KitchenSink = (): JSX.Element => {
|
2021-05-20 21:54:03 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{Object.keys(CallingButtonType).map(buttonType => (
|
|
|
|
<CallingButton
|
2021-08-05 15:22:00 +00:00
|
|
|
key={buttonType}
|
2021-05-20 21:54:03 +00:00
|
|
|
{...createProps({ buttonType: buttonType as CallingButtonType })}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const AudioOn = (): JSX.Element => {
|
2020-10-08 01:25:33 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.AUDIO_ON,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const AudioOff = (): JSX.Element => {
|
2020-10-08 01:25:33 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.AUDIO_OFF,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const AudioDisabled = (): JSX.Element => {
|
2020-10-14 16:30:50 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.AUDIO_DISABLED,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-14 16:30:50 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const VideoOn = (): JSX.Element => {
|
2020-10-08 01:25:33 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.VIDEO_ON,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const VideoOff = (): JSX.Element => {
|
2020-10-08 01:25:33 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.VIDEO_OFF,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const VideoDisabled = (): JSX.Element => {
|
2020-10-14 16:30:50 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.VIDEO_DISABLED,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-10-14 16:30:50 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const TooltipRight = (): JSX.Element => {
|
2020-10-08 01:25:33 +00:00
|
|
|
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} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TooltipRight.story = {
|
|
|
|
name: 'Tooltip right',
|
|
|
|
};
|
2021-05-20 21:54:03 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const PresentingOn = (): JSX.Element => {
|
2021-05-20 21:54:03 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.PRESENTING_ON,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2021-05-20 21:54:03 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const PresentingOff = (): JSX.Element => {
|
2021-05-20 21:54:03 +00:00
|
|
|
const props = createProps({
|
|
|
|
buttonType: CallingButtonType.PRESENTING_OFF,
|
|
|
|
});
|
|
|
|
return <CallingButton {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|