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

114 lines
2.9 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';
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';
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 => ({
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 => {
return (
<>
{Object.keys(CallingButtonType).map(buttonType => (
<CallingButton
key={buttonType}
{...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 => {
const props = createProps({
buttonType: CallingButtonType.AUDIO_DISABLED,
});
return <CallingButton {...props} />;
2022-06-07 00:48:02 +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 => {
const props = createProps({
buttonType: CallingButtonType.VIDEO_DISABLED,
});
return <CallingButton {...props} />;
2022-06-07 00:48:02 +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',
};
2022-06-07 00:48:02 +00:00
export const PresentingOn = (): JSX.Element => {
const props = createProps({
buttonType: CallingButtonType.PRESENTING_ON,
});
return <CallingButton {...props} />;
2022-06-07 00:48:02 +00:00
};
2022-06-07 00:48:02 +00:00
export const PresentingOff = (): JSX.Element => {
const props = createProps({
buttonType: CallingButtonType.PRESENTING_OFF,
});
return <CallingButton {...props} />;
2022-06-07 00:48:02 +00:00
};