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

186 lines
4.6 KiB
TypeScript
Raw Normal View History

// Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { action } from '@storybook/addon-actions';
2022-06-07 00:48:02 +00:00
import type { PropsType } from './DialogNetworkStatus';
import { DialogNetworkStatus } from './DialogNetworkStatus';
import { SocketStatus } from '../types/SocketStatus';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
import enMessages from '../../_locales/en/messages.json';
import { WidthBreakpoint } from './_util';
import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer';
const i18n = setupI18n('en', enMessages);
const defaultProps = {
containerWidthBreakpoint: WidthBreakpoint.Wide,
hasNetworkDialog: true,
i18n,
isOnline: true,
socketStatus: SocketStatus.CONNECTING,
manualReconnect: action('manual-reconnect'),
withinConnectingGracePeriod: false,
challengeStatus: 'idle' as const,
};
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/DialogNetworkStatus',
};
2022-11-18 00:45:19 +00:00
export function KnobsPlayground(args: PropsType): JSX.Element {
2022-06-07 00:48:02 +00:00
/*
const socketStatus = select(
'socketStatus',
{
CONNECTING: SocketStatus.CONNECTING,
OPEN: SocketStatus.OPEN,
CLOSING: SocketStatus.CLOSING,
CLOSED: SocketStatus.CLOSED,
},
SocketStatus.CONNECTING
);
2022-06-07 00:48:02 +00:00
*/
return (
2022-06-07 00:48:02 +00:00
<FakeLeftPaneContainer {...args}>
<DialogNetworkStatus {...defaultProps} {...args} />
</FakeLeftPaneContainer>
);
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
KnobsPlayground.args = {
containerWidthBreakpoint: WidthBreakpoint.Wide,
hasNetworkDialog: true,
isOnline: true,
socketStatus: SocketStatus.CONNECTING,
};
2022-11-18 00:45:19 +00:00
export function ConnectingWide(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Wide}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Wide}
socketStatus={SocketStatus.CONNECTING}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ConnectingWide.story = {
name: 'Connecting Wide',
};
2022-11-18 00:45:19 +00:00
export function ClosingWide(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Wide}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Wide}
socketStatus={SocketStatus.CLOSING}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ClosingWide.story = {
name: 'Closing Wide',
};
2022-11-18 00:45:19 +00:00
export function ClosedWide(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Wide}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Wide}
socketStatus={SocketStatus.CLOSED}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ClosedWide.story = {
name: 'Closed Wide',
};
2022-11-18 00:45:19 +00:00
export function OfflineWide(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Wide}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Wide}
isOnline={false}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
OfflineWide.story = {
name: 'Offline Wide',
};
2022-11-18 00:45:19 +00:00
export function ConnectingNarrow(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Narrow}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Narrow}
socketStatus={SocketStatus.CONNECTING}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ConnectingNarrow.story = {
name: 'Connecting Narrow',
};
2022-11-18 00:45:19 +00:00
export function ClosingNarrow(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Narrow}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Narrow}
socketStatus={SocketStatus.CLOSING}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ClosingNarrow.story = {
name: 'Closing Narrow',
};
2022-11-18 00:45:19 +00:00
export function ClosedNarrow(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Narrow}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Narrow}
socketStatus={SocketStatus.CLOSED}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
ClosedNarrow.story = {
name: 'Closed Narrow',
};
2022-11-18 00:45:19 +00:00
export function OfflineNarrow(): JSX.Element {
return (
<FakeLeftPaneContainer containerWidthBreakpoint={WidthBreakpoint.Narrow}>
<DialogNetworkStatus
{...defaultProps}
containerWidthBreakpoint={WidthBreakpoint.Narrow}
isOnline={false}
/>
</FakeLeftPaneContainer>
);
}
2022-06-07 00:48:02 +00:00
OfflineNarrow.story = {
name: 'Offline Narrow',
};