signal-desktop/ts/components/conversation/AudioCapture.stories.tsx

86 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-09-29 20:23:06 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import { select } from '@storybook/addon-knobs';
2021-09-29 20:23:06 +00:00
import {
ErrorDialogAudioRecorderType,
RecordingState,
} from '../../state/ducks/audioRecorder';
import type { PropsType } from './AudioCapture';
import { AudioCapture } from './AudioCapture';
2021-09-29 20:23:06 +00:00
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/AudioCapture',
};
2021-09-29 20:23:06 +00:00
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
cancelRecording: action('cancelRecording'),
completeRecording: action('completeRecording'),
conversationId: '123',
draftAttachments: [],
errorDialogAudioRecorderType: overrideProps.errorDialogAudioRecorderType,
errorRecording: action('errorRecording'),
i18n,
recordingState: select(
'recordingState',
RecordingState,
overrideProps.recordingState || RecordingState.Idle
),
2021-09-29 20:23:06 +00:00
onSendAudioRecording: action('onSendAudioRecording'),
startRecording: action('startRecording'),
});
2022-11-18 00:45:19 +00:00
export function Default(): JSX.Element {
2021-09-29 20:23:06 +00:00
return <AudioCapture {...createProps()} />;
2022-11-18 00:45:19 +00:00
}
2021-09-29 20:23:06 +00:00
2022-06-07 00:48:02 +00:00
export const _Initializing = (): JSX.Element => {
return (
<AudioCapture
{...createProps({
recordingState: RecordingState.Initializing,
})}
/>
);
2022-06-07 00:48:02 +00:00
};
2022-06-07 00:48:02 +00:00
export const _Recording = (): JSX.Element => {
2021-09-29 20:23:06 +00:00
return (
<AudioCapture
{...createProps({
recordingState: RecordingState.Recording,
2021-09-29 20:23:06 +00:00
})}
/>
);
2022-06-07 00:48:02 +00:00
};
2021-09-29 20:23:06 +00:00
2022-11-18 00:45:19 +00:00
export function VoiceLimit(): JSX.Element {
2021-09-29 20:23:06 +00:00
return (
<AudioCapture
{...createProps({
errorDialogAudioRecorderType: ErrorDialogAudioRecorderType.Timeout,
recordingState: RecordingState.Recording,
2021-09-29 20:23:06 +00:00
})}
/>
);
2022-11-18 00:45:19 +00:00
}
2021-09-29 20:23:06 +00:00
2022-11-18 00:45:19 +00:00
export function SwitchedApps(): JSX.Element {
2021-09-29 20:23:06 +00:00
return (
<AudioCapture
{...createProps({
errorDialogAudioRecorderType: ErrorDialogAudioRecorderType.Blur,
recordingState: RecordingState.Recording,
2021-09-29 20:23:06 +00:00
})}
/>
);
2022-11-18 00:45:19 +00:00
}