Upgrade react and storybook

This commit is contained in:
Josh Perez 2022-06-06 20:48:02 -04:00 committed by GitHub
parent 6476a4fe73
commit 42eb4013d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
244 changed files with 15341 additions and 10249 deletions

View file

@ -3,7 +3,6 @@
import React, { useState } from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { setupI18n } from '../../util/setupI18n';
@ -13,12 +12,11 @@ import { InstallScreenChoosingDeviceNameStep } from './InstallScreenChoosingDevi
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/InstallScreen/InstallScreenChoosingDeviceNameStep',
module
);
export default {
title: 'Components/InstallScreen/InstallScreenChoosingDeviceNameStep',
};
story.add('Default', () => {
export const Default = (): JSX.Element => {
const Wrapper = () => {
const [deviceName, setDeviceName] = useState<string>('Default value');
@ -33,4 +31,4 @@ story.add('Default', () => {
};
return <Wrapper />;
});
};

View file

@ -3,7 +3,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { setupI18n } from '../../util/setupI18n';
@ -13,10 +12,9 @@ import { InstallScreenErrorStep, InstallError } from './InstallScreenErrorStep';
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/InstallScreen/InstallScreenErrorStep',
module
);
export default {
title: 'Components/InstallScreen/InstallScreenErrorStep',
};
const defaultProps = {
i18n,
@ -24,28 +22,48 @@ const defaultProps = {
tryAgain: action('tryAgain'),
};
story.add('Too many devices', () => (
export const _TooManyDevices = (): JSX.Element => (
<InstallScreenErrorStep
{...defaultProps}
error={InstallError.TooManyDevices}
/>
));
);
story.add('Too old', () => (
_TooManyDevices.story = {
name: 'Too many devices',
};
export const _TooOld = (): JSX.Element => (
<InstallScreenErrorStep {...defaultProps} error={InstallError.TooOld} />
));
);
story.add('Too old', () => (
_TooOld.story = {
name: 'Too old',
};
export const __TooOld = (): JSX.Element => (
<InstallScreenErrorStep {...defaultProps} error={InstallError.TooOld} />
));
);
story.add('Connection failed', () => (
__TooOld.story = {
name: 'Too old',
};
export const _ConnectionFailed = (): JSX.Element => (
<InstallScreenErrorStep
{...defaultProps}
error={InstallError.ConnectionFailed}
/>
));
);
story.add('Unknown error', () => (
_ConnectionFailed.story = {
name: 'Connection failed',
};
export const _UnknownError = (): JSX.Element => (
<InstallScreenErrorStep {...defaultProps} error={InstallError.UnknownError} />
));
);
_UnknownError.story = {
name: 'Unknown error',
};

View file

@ -3,8 +3,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
@ -12,9 +10,10 @@ import { InstallScreenLinkInProgressStep } from './InstallScreenLinkInProgressSt
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/InstallScreen/InstallScreenLinkInProgressStep',
module
);
export default {
title: 'Components/InstallScreen/InstallScreenLinkInProgressStep',
};
story.add('Default', () => <InstallScreenLinkInProgressStep i18n={i18n} />);
export const Default = (): JSX.Element => (
<InstallScreenLinkInProgressStep i18n={i18n} />
);

View file

@ -3,8 +3,6 @@
import React, { useEffect, useState } from 'react';
import { storiesOf } from '@storybook/react';
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
@ -14,10 +12,9 @@ import { InstallScreenQrCodeNotScannedStep } from './InstallScreenQrCodeNotScann
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/InstallScreen/InstallScreenQrCodeNotScannedStep',
module
);
export default {
title: 'Components/InstallScreen/InstallScreenQrCodeNotScannedStep',
};
const Simulation = ({ finalResult }: { finalResult: Loadable<string> }) => {
const [provisioningUrl, setProvisioningUrl] = useState<Loadable<string>>({
@ -41,16 +38,20 @@ const Simulation = ({ finalResult }: { finalResult: Loadable<string> }) => {
);
};
story.add('QR code loading', () => (
export const QrCodeLoading = (): JSX.Element => (
<InstallScreenQrCodeNotScannedStep
i18n={i18n}
provisioningUrl={{
loadingState: LoadingState.Loading,
}}
/>
));
);
story.add('QR code failed to load', () => (
QrCodeLoading.story = {
name: 'QR code loading',
};
export const QrCodeFailedToLoad = (): JSX.Element => (
<InstallScreenQrCodeNotScannedStep
i18n={i18n}
provisioningUrl={{
@ -58,9 +59,13 @@ story.add('QR code failed to load', () => (
error: new Error('uh oh'),
}}
/>
));
);
story.add('QR code loaded', () => (
QrCodeFailedToLoad.story = {
name: 'QR code failed to load',
};
export const QrCodeLoaded = (): JSX.Element => (
<InstallScreenQrCodeNotScannedStep
i18n={i18n}
provisioningUrl={{
@ -69,9 +74,13 @@ story.add('QR code loaded', () => (
'https://example.com/fake-signal-link?uuid=56cdd548-e595-4962-9a27-3f1e8210a959&pub_key=SW4gdGhlIHZhc3QsIGRlZXAgZm9yZXN0IG9mIEh5cnVsZS4uLg%3D%3D',
}}
/>
));
);
story.add('Simulated loading', () => (
QrCodeLoaded.story = {
name: 'QR code loaded',
};
export const SimulatedLoading = (): JSX.Element => (
<Simulation
finalResult={{
loadingState: LoadingState.Loaded,
@ -79,13 +88,21 @@ story.add('Simulated loading', () => (
'https://example.com/fake-signal-link?uuid=56cdd548-e595-4962-9a27-3f1e8210a959&pub_key=SW4gdGhlIHZhc3QsIGRlZXAgZm9yZXN0IG9mIEh5cnVsZS4uLg%3D%3D',
}}
/>
));
);
story.add('Simulated failure', () => (
SimulatedLoading.story = {
name: 'Simulated loading',
};
export const SimulatedFailure = (): JSX.Element => (
<Simulation
finalResult={{
loadingState: LoadingState.LoadFailed,
error: new Error('uh oh'),
}}
/>
));
);
SimulatedFailure.story = {
name: 'Simulated failure',
};