// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './DialogUpdate'; import { DialogUpdate } from './DialogUpdate'; import { DialogType } from '../types/Dialogs'; import { WidthBreakpoint } from './_util'; import { SECOND } from '../util/durations'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; import { setupI18n } from '../util/setupI18n'; import enMessages from '../../_locales/en/messages.json'; const i18n = setupI18n('en', enMessages); const defaultProps = { containerWidthBreakpoint: WidthBreakpoint.Wide, dismissDialog: action('dismiss-dialog'), downloadSize: 116504357, downloadedSize: 61003110, i18n, showEventsCount: 0, snoozeUpdate: action('snooze-update'), startUpdate: action('start-update'), version: 'v7.7.7', }; export default { title: 'Components/DialogUpdate', argTypes: {}, args: {}, } satisfies Meta; export function KnobsPlayground(): JSX.Element { const containerWidthBreakpoint = WidthBreakpoint.Wide; const dialogType = DialogType.AutoUpdate; return ( ); } export function UpdateWide(): JSX.Element { return ( ); } export function DownloadedWide(): JSX.Element { return ( ); } export function DownloadReadyWide(): JSX.Element { return ( ); } export function FullDownloadReadyWide(): JSX.Element { return ( ); } export function DownloadingWide(): JSX.Element { const [downloadedSize, setDownloadedSize] = React.useState(0); const { downloadSize } = defaultProps; React.useEffect(() => { const interval = setInterval(() => { setDownloadedSize(x => { const newValue = x + 0.25 * downloadSize; if (newValue > downloadSize) { return 0; } return newValue; }); }, SECOND); return () => clearInterval(interval); }, [downloadSize]); return ( ); } export function CannotUpdateWide(): JSX.Element { return ( ); } export function CannotUpdateBetaWide(): JSX.Element { return ( ); } export function CannotUpdateRequireManualWide(): JSX.Element { return ( ); } export function CannotUpdateRequireManualBetaWide(): JSX.Element { return ( ); } export function MacOSReadOnlyWide(): JSX.Element { return ( ); } export function UnsupportedOSWide(): JSX.Element { return ( ); } export function UpdateNarrow(): JSX.Element { return ( ); } export function DownloadedNarrow(): JSX.Element { return ( ); } export function DownloadReadyNarrow(): JSX.Element { return ( ); } export function FullDownloadReadyNarrow(): JSX.Element { return ( ); } export function DownloadingNarrow(): JSX.Element { return ( ); } export function CannotUpdateNarrow(): JSX.Element { return ( ); } export function CannotUpdateBetaNarrow(): JSX.Element { return ( ); } export function CannotUpdateRequireManualNarrow(): JSX.Element { return ( ); } export function CannotUpdateRequireManualBetaNarrow(): JSX.Element { return ( ); } export function MacOSReadOnlyNarrow(): JSX.Element { return ( ); } export function UnsupportedOSNarrow(): JSX.Element { return ( ); }