mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Merge pull request #17282 from storybookjs/feat/testing-utilities
Core/React: Add testing utilities
This commit is contained in:
commit
d3b4566eed
@ -9,6 +9,7 @@ export {
|
||||
raw,
|
||||
forceReRender,
|
||||
} from './preview';
|
||||
export * from './testing';
|
||||
|
||||
export * from './preview/types-6-3';
|
||||
|
||||
|
129
app/react/src/client/testing/index.ts
Normal file
129
app/react/src/client/testing/index.ts
Normal file
@ -0,0 +1,129 @@
|
||||
import {
|
||||
composeStory as originalComposeStory,
|
||||
composeStories as originalComposeStories,
|
||||
setProjectAnnotations as originalSetProjectAnnotations,
|
||||
CSFExports,
|
||||
ComposedStory,
|
||||
StoriesWithPartialProps,
|
||||
} from '@storybook/store';
|
||||
import { ProjectAnnotations, Args } from '@storybook/csf';
|
||||
import { once } from '@storybook/client-logger';
|
||||
|
||||
import { render } from '../preview/render';
|
||||
import type { Meta, ReactFramework } from '../preview/types-6-0';
|
||||
|
||||
/** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
|
||||
*
|
||||
* It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
|
||||
*
|
||||
* Example:
|
||||
*```jsx
|
||||
* // setup.js (for jest)
|
||||
* import { setProjectAnnotations } from '@storybook/react';
|
||||
* import * as projectAnnotations from './.storybook/preview';
|
||||
*
|
||||
* setProjectAnnotations(projectAnnotations);
|
||||
*```
|
||||
*
|
||||
* @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
|
||||
*/
|
||||
export function setProjectAnnotations(
|
||||
projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]
|
||||
) {
|
||||
originalSetProjectAnnotations(projectAnnotations);
|
||||
}
|
||||
|
||||
/** Preserved for users migrating from `@storybook/testing-react`.
|
||||
*
|
||||
* @deprecated Use setProjectAnnotations instead
|
||||
*/
|
||||
export function setGlobalConfig(
|
||||
projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]
|
||||
) {
|
||||
once.warn(`setGlobalConfig is deprecated. Use setProjectAnnotations instead.`);
|
||||
setProjectAnnotations(projectAnnotations);
|
||||
}
|
||||
|
||||
// This will not be necessary once we have auto preset loading
|
||||
const defaultProjectAnnotations: ProjectAnnotations<ReactFramework> = {
|
||||
render,
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that will receive a story along with meta (e.g. a default export from a .stories file)
|
||||
* and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
|
||||
* and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
|
||||
*
|
||||
*
|
||||
* It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
|
||||
*
|
||||
* Example:
|
||||
*```jsx
|
||||
* import { render } from '@testing-library/react';
|
||||
* import { composeStory } from '@storybook/react';
|
||||
* import Meta, { Primary as PrimaryStory } from './Button.stories';
|
||||
*
|
||||
* const Primary = composeStory(PrimaryStory, Meta);
|
||||
*
|
||||
* test('renders primary button with Hello World', () => {
|
||||
* const { getByText } = render(<Primary>Hello world</Primary>);
|
||||
* expect(getByText(/Hello world/i)).not.toBeNull();
|
||||
* });
|
||||
*```
|
||||
*
|
||||
* @param story
|
||||
* @param componentAnnotations - e.g. (import Meta from './Button.stories')
|
||||
* @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
||||
* @param [exportsName] - in case your story does not contain a name and you want it to have a name.
|
||||
*/
|
||||
export function composeStory<TArgs = Args>(
|
||||
story: ComposedStory<ReactFramework, TArgs>,
|
||||
componentAnnotations: Meta<TArgs | any>,
|
||||
projectAnnotations?: ProjectAnnotations<ReactFramework>,
|
||||
exportsName?: string
|
||||
) {
|
||||
return originalComposeStory<ReactFramework, TArgs>(
|
||||
story,
|
||||
componentAnnotations,
|
||||
projectAnnotations,
|
||||
defaultProjectAnnotations,
|
||||
exportsName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
|
||||
* and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
|
||||
* and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
|
||||
*
|
||||
*
|
||||
* It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
|
||||
*
|
||||
* Example:
|
||||
*```jsx
|
||||
* import { render } from '@testing-library/react';
|
||||
* import { composeStories } from '@storybook/react';
|
||||
* import * as stories from './Button.stories';
|
||||
*
|
||||
* const { Primary, Secondary } = composeStories(stories);
|
||||
*
|
||||
* test('renders primary button with Hello World', () => {
|
||||
* const { getByText } = render(<Primary>Hello world</Primary>);
|
||||
* expect(getByText(/Hello world/i)).not.toBeNull();
|
||||
* });
|
||||
*```
|
||||
*
|
||||
* @param csfExports - e.g. (import * as stories from './Button.stories')
|
||||
* @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
||||
*/
|
||||
export function composeStories<TModule extends CSFExports<ReactFramework>>(
|
||||
csfExports: TModule,
|
||||
projectAnnotations?: ProjectAnnotations<ReactFramework>
|
||||
) {
|
||||
const composedStories = originalComposeStories(csfExports, projectAnnotations, composeStory);
|
||||
|
||||
return composedStories as unknown as Omit<
|
||||
StoriesWithPartialProps<ReactFramework, TModule>,
|
||||
keyof CSFExports
|
||||
>;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
import type { StorybookConfig } from '@storybook/react/types';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
const mainConfig: StorybookConfig = {
|
||||
stories: ['../src/**/*.stories.@(tsx|mdx)'],
|
||||
addons: [
|
||||
'@storybook/preset-create-react-app',
|
||||
@ -13,9 +15,9 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
logLevel: 'debug',
|
||||
webpackFinal: (config) => {
|
||||
webpackFinal: async (config) => {
|
||||
// add monorepo root as a valid directory to import modules from
|
||||
config.resolve.plugins.forEach((p) => {
|
||||
config.resolve?.plugins?.forEach((p: any) => {
|
||||
if (Array.isArray(p.appSrcs)) {
|
||||
p.appSrcs.push(path.join(__dirname, '..', '..', '..'));
|
||||
}
|
||||
@ -30,3 +32,5 @@ module.exports = {
|
||||
buildStoriesJson: true,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = mainConfig;
|
@ -1,14 +1,25 @@
|
||||
import React from 'react';
|
||||
import type { DecoratorFn } from '@storybook/react';
|
||||
import { ThemeProvider, convert, themes } from '@storybook/theming';
|
||||
|
||||
export const decorators = [
|
||||
(StoryFn, { globals: { locale = 'en' } }) => (
|
||||
export const decorators: DecoratorFn[] = [
|
||||
(StoryFn, { globals: { locale } }) => (
|
||||
<>
|
||||
<div>{locale}</div>
|
||||
<div>Locale: {locale}</div>
|
||||
<StoryFn />
|
||||
</>
|
||||
),
|
||||
(StoryFn) => (
|
||||
<ThemeProvider theme={convert(themes.light)}>
|
||||
<StoryFn />
|
||||
</ThemeProvider>
|
||||
),
|
||||
];
|
||||
|
||||
export const parameters = {
|
||||
actions: { argTypesRegex: '^on[A-Z].*' },
|
||||
};
|
||||
|
||||
export const globalTypes = {
|
||||
locale: {
|
||||
name: 'Locale',
|
@ -8,7 +8,7 @@
|
||||
"eject": "react-scripts eject",
|
||||
"start": "react-scripts start",
|
||||
"storybook": "start-storybook -p 9009 --no-manager-cache",
|
||||
"test": "react-scripts test"
|
||||
"test": "SKIP_PREFLIGHT_CHECK=true react-scripts test"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
@ -23,10 +23,13 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/components": "6.5.0-alpha.51",
|
||||
"@storybook/theming": "6.5.0-alpha.51",
|
||||
"@types/jest": "^26.0.16",
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"@types/react": "^16.14.23",
|
||||
"@types/react-dom": "^16.9.14",
|
||||
"@types/react-dom": "16.9.14",
|
||||
"formik": "2.2.9",
|
||||
"global": "^4.4.0",
|
||||
"react": "16.14.0",
|
||||
"react-dom": "16.14.0",
|
||||
@ -40,6 +43,7 @@
|
||||
"@storybook/builder-webpack4": "6.5.0-alpha.52",
|
||||
"@storybook/preset-create-react-app": "^3.1.6",
|
||||
"@storybook/react": "6.5.0-alpha.52",
|
||||
"@storybook/testing-library": "^0.0.9",
|
||||
"webpack": "4"
|
||||
},
|
||||
"storybook": {
|
||||
|
4
examples/cra-ts-essentials/src/setupTests.ts
Normal file
4
examples/cra-ts-essentials/src/setupTests.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { setProjectAnnotations } from '@storybook/react';
|
||||
import * as projectAnnotations from '../.storybook/preview';
|
||||
|
||||
setProjectAnnotations(projectAnnotations);
|
@ -1,12 +1,15 @@
|
||||
import React from 'react';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
component: Welcome,
|
||||
};
|
||||
} as ComponentMeta<typeof Welcome>;
|
||||
|
||||
export const ToStorybook = () => <Welcome showApp={linkTo('Button')} />;
|
||||
export const ToStorybook: ComponentStory<typeof Welcome> = () => (
|
||||
<Welcome showApp={linkTo('Button')} />
|
||||
);
|
||||
|
||||
ToStorybook.storyName = 'to Storybook';
|
||||
|
@ -1,13 +1,14 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
component: Button,
|
||||
argTypes: { onClick: { action: 'clicked' } },
|
||||
};
|
||||
} as ComponentMeta<typeof Button>;
|
||||
|
||||
const Template = (args: any) => <Button {...args} />;
|
||||
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
|
||||
|
||||
export const Text = Template.bind({});
|
||||
Text.args = {
|
||||
|
@ -0,0 +1,119 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import React from 'react';
|
||||
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react';
|
||||
import { userEvent, within } from '@storybook/testing-library';
|
||||
|
||||
import { AccountForm, AccountFormProps } from './AccountForm';
|
||||
|
||||
export default {
|
||||
title: 'CSF3/AccountForm',
|
||||
component: AccountForm,
|
||||
parameters: {
|
||||
layout: 'centered',
|
||||
},
|
||||
} as ComponentMeta<typeof AccountForm>;
|
||||
|
||||
type Story = ComponentStoryObj<typeof AccountForm>;
|
||||
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
export const Standard: Story = {
|
||||
args: { passwordVerification: false },
|
||||
};
|
||||
|
||||
export const StandardEmailFilled: Story = {
|
||||
...Standard,
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByTestId('email'), 'michael@chromatic.com');
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardEmailFailed: Story = {
|
||||
...Standard,
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByTestId('email'), 'michael@chromatic.com.com@com');
|
||||
await userEvent.type(canvas.getByTestId('password1'), 'testpasswordthatwontfail');
|
||||
await userEvent.click(canvas.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardPasswordFailed: Story = {
|
||||
...Standard,
|
||||
play: async (context) => {
|
||||
const canvas = within(context.canvasElement);
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(canvas.getByTestId('password1'), 'asdf');
|
||||
await userEvent.click(canvas.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardFailHover: Story = {
|
||||
...StandardPasswordFailed,
|
||||
play: async (context) => {
|
||||
const canvas = within(context.canvasElement);
|
||||
await StandardPasswordFailed.play!(context);
|
||||
await sleep(100);
|
||||
await userEvent.hover(canvas.getByTestId('password-error-info'));
|
||||
},
|
||||
};
|
||||
StandardFailHover.parameters = {
|
||||
// IE fails with userEvent.hover
|
||||
chromatic: { disableSnapshot: true },
|
||||
};
|
||||
|
||||
export const Verification: Story = {
|
||||
args: { passwordVerification: true },
|
||||
};
|
||||
|
||||
export const VerificationPasssword1: Story = {
|
||||
...Verification,
|
||||
play: async (context) => {
|
||||
const canvas = within(context.canvasElement);
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(canvas.getByTestId('password1'), 'asdfasdf');
|
||||
await userEvent.click(canvas.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const VerificationPasswordMismatch: Story = {
|
||||
...Verification,
|
||||
play: async (context) => {
|
||||
const canvas = within(context.canvasElement);
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(canvas.getByTestId('password1'), 'asdfasdf');
|
||||
await userEvent.type(canvas.getByTestId('password2'), 'asdf1234');
|
||||
await userEvent.click(canvas.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const VerificationSuccess: Story = {
|
||||
...Verification,
|
||||
play: async (context) => {
|
||||
const canvas = within(context.canvasElement);
|
||||
await StandardEmailFilled.play!(context);
|
||||
await sleep(1000);
|
||||
await userEvent.type(canvas.getByTestId('password1'), 'asdfasdf', { delay: 50 });
|
||||
await sleep(1000);
|
||||
await userEvent.type(canvas.getByTestId('password2'), 'asdfasdf', { delay: 50 });
|
||||
await sleep(1000);
|
||||
await userEvent.click(canvas.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
// IE fails with this interaction
|
||||
VerificationSuccess.parameters = {
|
||||
chromatic: {
|
||||
disableSnapshot: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardWithRenderFunction: Story = {
|
||||
...Standard,
|
||||
render: (args: AccountFormProps) => (
|
||||
<div>
|
||||
<p>This uses a custom render</p>
|
||||
<AccountForm {...args} />
|
||||
</div>
|
||||
),
|
||||
};
|
@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { composeStories, composeStory } from '@storybook/react';
|
||||
|
||||
import * as stories from './AccountForm.stories';
|
||||
|
||||
const { Standard } = composeStories(stories);
|
||||
|
||||
test('renders form', async () => {
|
||||
await render(<Standard />);
|
||||
expect(screen.getByTestId('email')).not.toBe(null);
|
||||
});
|
||||
|
||||
test('fills input from play function', async () => {
|
||||
const StandardEmailFilled = composeStory(stories.StandardEmailFilled, stories.default);
|
||||
const { container } = await render(<StandardEmailFilled />);
|
||||
|
||||
await StandardEmailFilled.play({ canvasElement: container });
|
||||
|
||||
const emailInput = screen.getByTestId('email') as HTMLInputElement;
|
||||
expect(emailInput.value).toBe('michael@chromatic.com');
|
||||
});
|
@ -0,0 +1,552 @@
|
||||
import React, { FC, HTMLAttributes, useCallback, useState } from 'react';
|
||||
import { keyframes, styled } from '@storybook/theming';
|
||||
import {
|
||||
ErrorMessage,
|
||||
Field as FormikInput,
|
||||
Form as FormikForm,
|
||||
Formik,
|
||||
FormikProps,
|
||||
} from 'formik';
|
||||
import { Icons, WithTooltip } from '@storybook/components';
|
||||
|
||||
const errorMap = {
|
||||
email: {
|
||||
required: {
|
||||
normal: 'Please enter your email address',
|
||||
tooltip:
|
||||
'We do require an email address and a password as a minimum in order to be able to create an account for you to log in with',
|
||||
},
|
||||
format: {
|
||||
normal: 'Please enter a correctly formatted email address',
|
||||
tooltip:
|
||||
'Your email address is formatted incorrectly and is not correct - please double check for misspelling',
|
||||
},
|
||||
},
|
||||
password: {
|
||||
required: {
|
||||
normal: 'Please enter a password',
|
||||
tooltip: 'A password is requried to create an account',
|
||||
},
|
||||
length: {
|
||||
normal: 'Please enter a password of minimum 6 characters',
|
||||
tooltip:
|
||||
'For security reasons we enforce a password length of minimum 6 characters - but have no other requirements',
|
||||
},
|
||||
},
|
||||
verifiedPassword: {
|
||||
required: {
|
||||
normal: 'Please verify your password',
|
||||
tooltip:
|
||||
'Verification of your password is required to ensure no errors in the spelling of the password',
|
||||
},
|
||||
match: {
|
||||
normal: 'Your passwords do not match',
|
||||
tooltip:
|
||||
'Your verification password has to match your password to make sure you have not misspelled',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// https://emailregex.com/
|
||||
const email99RegExp = new RegExp(
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
);
|
||||
|
||||
export interface AccountFormResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface AccountFormValues {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface FormValues extends AccountFormValues {
|
||||
verifiedPassword: string;
|
||||
}
|
||||
|
||||
interface FormErrors {
|
||||
email?: string;
|
||||
emailTooltip?: string;
|
||||
password?: string;
|
||||
passwordTooltip?: string;
|
||||
verifiedPassword?: string;
|
||||
verifiedPasswordTooltip?: string;
|
||||
}
|
||||
|
||||
export type AccountFormProps = {
|
||||
passwordVerification?: boolean;
|
||||
onSubmit?: (values: AccountFormValues) => void;
|
||||
onTransactionStart?: (values: AccountFormValues) => void;
|
||||
onTransactionEnd?: (values: AccountFormResponse) => void;
|
||||
};
|
||||
|
||||
export const AccountForm: FC<AccountFormProps> = ({
|
||||
passwordVerification,
|
||||
onSubmit,
|
||||
onTransactionStart,
|
||||
onTransactionEnd,
|
||||
}) => {
|
||||
const [state, setState] = useState({
|
||||
transacting: false,
|
||||
transactionSuccess: false,
|
||||
transactionFailure: false,
|
||||
});
|
||||
|
||||
const handleFormSubmit = useCallback(
|
||||
async ({ email, password }: FormValues, { setSubmitting, resetForm }) => {
|
||||
if (onSubmit) {
|
||||
onSubmit({ email, password });
|
||||
}
|
||||
|
||||
if (onTransactionStart) {
|
||||
onTransactionStart({ email, password });
|
||||
}
|
||||
|
||||
setSubmitting(true);
|
||||
|
||||
setState({
|
||||
...state,
|
||||
transacting: true,
|
||||
});
|
||||
|
||||
await new Promise((r) => setTimeout(r, 2100));
|
||||
|
||||
const success = Math.random() < 1;
|
||||
|
||||
if (onTransactionEnd) {
|
||||
onTransactionEnd({ success });
|
||||
}
|
||||
|
||||
setSubmitting(false);
|
||||
resetForm({ values: { email: '', password: '', verifiedPassword: '' } });
|
||||
|
||||
setState({
|
||||
...state,
|
||||
transacting: false,
|
||||
transactionSuccess: success === true,
|
||||
transactionFailure: success === false,
|
||||
});
|
||||
},
|
||||
[setState, onTransactionEnd, onTransactionStart]
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<Brand>
|
||||
<Logo
|
||||
aria-label="Storybook Logo"
|
||||
viewBox="0 0 64 64"
|
||||
transacting={state.transacting}
|
||||
role="img"
|
||||
>
|
||||
<title>Storybook icon</title>
|
||||
<g id="Artboard" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
||||
<path
|
||||
d="M8.04798541,58.7875918 L6.07908839,6.32540407 C6.01406344,4.5927838 7.34257463,3.12440831 9.07303814,3.01625434 L53.6958037,0.227331489 C55.457209,0.117243658 56.974354,1.45590096 57.0844418,3.21730626 C57.0885895,3.28366922 57.0906648,3.35014546 57.0906648,3.41663791 L57.0906648,60.5834697 C57.0906648,62.3483119 55.6599776,63.7789992 53.8951354,63.7789992 C53.847325,63.7789992 53.7995207,63.7779262 53.7517585,63.775781 L11.0978899,61.8600599 C9.43669044,61.7854501 8.11034889,60.4492961 8.04798541,58.7875918 Z"
|
||||
id="path-1"
|
||||
fill="#FF4785"
|
||||
fillRule="nonzero"
|
||||
/>
|
||||
<path
|
||||
d="M35.9095005,24.1768792 C35.9095005,25.420127 44.2838488,24.8242707 45.4080313,23.9509748 C45.4080313,15.4847538 40.8652557,11.0358878 32.5466666,11.0358878 C24.2280775,11.0358878 19.5673077,15.553972 19.5673077,22.3311017 C19.5673077,34.1346028 35.4965208,34.3605071 35.4965208,40.7987804 C35.4965208,42.606015 34.6115646,43.6790606 32.6646607,43.6790606 C30.127786,43.6790606 29.1248356,42.3834613 29.2428298,37.9783269 C29.2428298,37.0226907 19.5673077,36.7247626 19.2723223,37.9783269 C18.5211693,48.6535354 25.1720308,51.7326752 32.7826549,51.7326752 C40.1572906,51.7326752 45.939005,47.8018145 45.939005,40.6858282 C45.939005,28.035186 29.7738035,28.3740425 29.7738035,22.1051974 C29.7738035,19.5637737 31.6617103,19.2249173 32.7826549,19.2249173 C33.9625966,19.2249173 36.0864917,19.4328883 35.9095005,24.1768792 Z"
|
||||
id="path9_fill-path"
|
||||
fill="#FFFFFF"
|
||||
fillRule="nonzero"
|
||||
/>
|
||||
<path
|
||||
d="M44.0461638,0.830433986 L50.1874092,0.446606143 L50.443532,7.7810017 C50.4527198,8.04410717 50.2468789,8.26484453 49.9837734,8.27403237 C49.871115,8.27796649 49.7607078,8.24184808 49.6721567,8.17209069 L47.3089847,6.3104681 L44.5110468,8.43287463 C44.3012992,8.591981 44.0022839,8.55092814 43.8431776,8.34118051 C43.7762017,8.25288717 43.742082,8.14401677 43.7466857,8.03329059 L44.0461638,0.830433986 Z"
|
||||
id="Path"
|
||||
fill="#FFFFFF"
|
||||
/>
|
||||
</g>
|
||||
</Logo>
|
||||
<Title aria-label="Storybook" viewBox="0 0 200 40" role="img">
|
||||
<title>Storybook</title>
|
||||
<g fill="none" fillRule="evenodd">
|
||||
<path
|
||||
d="M53.3 31.7c-1.7 0-3.4-.3-5-.7-1.5-.5-2.8-1.1-3.9-2l1.6-3.5c2.2 1.5 4.6 2.3 7.3 2.3 1.5 0 2.5-.2 3.3-.7.7-.5 1.1-1 1.1-1.9 0-.7-.3-1.3-1-1.7s-2-.8-3.7-1.2c-2-.4-3.6-.9-4.8-1.5-1.1-.5-2-1.2-2.6-2-.5-1-.8-2-.8-3.2 0-1.4.4-2.6 1.2-3.6.7-1.1 1.8-2 3.2-2.6 1.3-.6 2.9-.9 4.7-.9 1.6 0 3.1.3 4.6.7 1.5.5 2.7 1.1 3.5 2l-1.6 3.5c-2-1.5-4.2-2.3-6.5-2.3-1.3 0-2.3.2-3 .8-.8.5-1.2 1.1-1.2 2 0 .5.2 1 .5 1.3.2.3.7.6 1.4.9l2.9.8c2.9.6 5 1.4 6.2 2.4a5 5 0 0 1 2 4.2 6 6 0 0 1-2.5 5c-1.7 1.2-4 1.9-7 1.9zm21-3.6l1.4-.1-.2 3.5-1.9.1c-2.4 0-4.1-.5-5.2-1.5-1.1-1-1.6-2.7-1.6-4.8v-6h-3v-3.6h3V11h4.8v4.6h4v3.6h-4v6c0 1.8.9 2.8 2.6 2.8zm11.1 3.5c-1.6 0-3-.3-4.3-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.3-1 1.7 0 3.2.3 4.4 1a7 7 0 0 1 3 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.4 1zm0-3.6c2.4 0 3.6-1.6 3.6-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.6-1c-2.3 0-3.5 1.4-3.5 4.4 0 3 1.2 4.6 3.5 4.6zm21.7-8.8l-2.7.3c-1.3.2-2.3.5-2.8 1.2-.6.6-.9 1.4-.9 2.5v8.2H96V15.7h4.6v2.6c.8-1.8 2.5-2.8 5-3h1.3l.3 4zm14-3.5h4.8L116.4 37h-4.9l3-6.6-6.4-14.8h5l4 10 4-10zm16-.4c1.4 0 2.6.3 3.6 1 1 .6 1.9 1.6 2.5 2.8.6 1.2.9 2.7.9 4.3 0 1.6-.3 3-1 4.3a6.9 6.9 0 0 1-2.4 2.9c-1 .7-2.2 1-3.6 1-1 0-2-.2-3-.7-.8-.4-1.5-1-2-1.9v2.4h-4.7V8.8h4.8v9c.5-.8 1.2-1.4 2-1.9.9-.4 1.8-.6 3-.6zM135.7 28c1.1 0 2-.4 2.6-1.2.6-.8 1-2 1-3.4 0-1.5-.4-2.5-1-3.3s-1.5-1.1-2.6-1.1-2 .3-2.6 1.1c-.6.8-1 2-1 3.3 0 1.5.4 2.6 1 3.4.6.8 1.5 1.2 2.6 1.2zm18.9 3.6c-1.7 0-3.2-.3-4.4-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.4-1 1.6 0 3 .3 4.3 1a7 7 0 0 1 3 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.3 1zm0-3.6c2.3 0 3.5-1.6 3.5-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.5-1c-2.4 0-3.6 1.4-3.6 4.4 0 3 1.2 4.6 3.6 4.6zm18 3.6c-1.7 0-3.2-.3-4.4-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.4-1 1.6 0 3 .3 4.4 1a7 7 0 0 1 2.9 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.3 1zm0-3.6c2.3 0 3.5-1.6 3.5-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.5-1c-2.4 0-3.6 1.4-3.6 4.4 0 3 1.2 4.6 3.6 4.6zm27.4 3.4h-6l-6-7v7h-4.8V8.8h4.9v13.6l5.8-6.7h5.7l-6.6 7.5 7 8.2z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</g>
|
||||
</Title>
|
||||
</Brand>
|
||||
{!state.transactionSuccess && !state.transactionFailure && (
|
||||
<Introduction>Create an account to join the Storybook community</Introduction>
|
||||
)}
|
||||
<Content>
|
||||
{state.transactionSuccess && !state.transactionFailure && (
|
||||
<Presentation>
|
||||
<p>
|
||||
Everything is perfect. Your account is ready and we should probably get you started!
|
||||
</p>
|
||||
<p>So why don't you get started then?</p>
|
||||
<Submit
|
||||
dirty
|
||||
onClick={() => {
|
||||
setState({
|
||||
transacting: false,
|
||||
transactionSuccess: false,
|
||||
transactionFailure: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Go back
|
||||
</Submit>
|
||||
</Presentation>
|
||||
)}
|
||||
{state.transactionFailure && !state.transactionSuccess && (
|
||||
<Presentation>
|
||||
<p>What a mess, this API is not working</p>
|
||||
<p>
|
||||
Someone should probably have a stern talking to about this, but it won't be me - coz
|
||||
I'm gonna head out into the nice weather
|
||||
</p>
|
||||
<Submit
|
||||
dirty
|
||||
onClick={() => {
|
||||
setState({
|
||||
transacting: false,
|
||||
transactionSuccess: false,
|
||||
transactionFailure: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Go back
|
||||
</Submit>
|
||||
</Presentation>
|
||||
)}
|
||||
{!state.transactionSuccess && !state.transactionFailure && (
|
||||
<Formik
|
||||
initialValues={{ email: '', password: '', verifiedPassword: '' }}
|
||||
validateOnBlur={false}
|
||||
validateOnChange={false}
|
||||
onSubmit={handleFormSubmit}
|
||||
validate={({ email, password, verifiedPassword }) => {
|
||||
const errors: FormErrors = {};
|
||||
|
||||
if (!email) {
|
||||
errors.email = errorMap.email.required.normal;
|
||||
errors.emailTooltip = errorMap.email.required.tooltip;
|
||||
} else {
|
||||
const validEmail = email.match(email99RegExp);
|
||||
|
||||
if (validEmail === null) {
|
||||
errors.email = errorMap.email.format.normal;
|
||||
errors.emailTooltip = errorMap.email.format.tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
errors.password = errorMap.password.required.normal;
|
||||
errors.passwordTooltip = errorMap.password.required.tooltip;
|
||||
} else if (password.length < 6) {
|
||||
errors.password = errorMap.password.length.normal;
|
||||
errors.passwordTooltip = errorMap.password.length.tooltip;
|
||||
}
|
||||
|
||||
if (passwordVerification && !verifiedPassword) {
|
||||
errors.verifiedPassword = errorMap.verifiedPassword.required.normal;
|
||||
errors.verifiedPasswordTooltip = errorMap.verifiedPassword.required.tooltip;
|
||||
} else if (passwordVerification && password !== verifiedPassword) {
|
||||
errors.verifiedPassword = errorMap.verifiedPassword.match.normal;
|
||||
errors.verifiedPasswordTooltip = errorMap.verifiedPassword.match.tooltip;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}}
|
||||
>
|
||||
{({ errors: _errors, isSubmitting, dirty }: FormikProps<FormValues>) => {
|
||||
const errors = _errors as FormErrors;
|
||||
|
||||
return (
|
||||
<Form noValidate aria-disabled={isSubmitting ? 'true' : 'false'}>
|
||||
<FieldWrapper>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<FormikInput id="email" name="email">
|
||||
{({ field }: { field: HTMLAttributes<HTMLInputElement> }) => (
|
||||
<>
|
||||
<Input
|
||||
data-testid="email"
|
||||
aria-required="true"
|
||||
aria-disabled={isSubmitting ? 'true' : 'false'}
|
||||
disabled={isSubmitting}
|
||||
type="email"
|
||||
aria-invalid={errors.email ? 'true' : 'false'}
|
||||
{...field}
|
||||
/>
|
||||
{errors.email && (
|
||||
<WithTooltip
|
||||
tooltip={<ErrorTooltip>{errors.emailTooltip}</ErrorTooltip>}
|
||||
>
|
||||
<ErrorWrapper>
|
||||
<ErrorIcon icon="question" height={14} />
|
||||
<Error name="email" component="div" />
|
||||
</ErrorWrapper>
|
||||
</WithTooltip>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</FormikInput>
|
||||
</FieldWrapper>
|
||||
<FieldWrapper>
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<FormikInput id="password" name="password">
|
||||
{({ field }: { field: HTMLAttributes<HTMLInputElement> }) => (
|
||||
<Input
|
||||
data-testid="password1"
|
||||
aria-required="true"
|
||||
aria-disabled={isSubmitting ? 'true' : 'false'}
|
||||
aria-invalid={errors.password ? 'true' : 'false'}
|
||||
type="password"
|
||||
disabled={isSubmitting}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
</FormikInput>
|
||||
{errors.password && (
|
||||
<WithTooltip tooltip={<ErrorTooltip>{errors.passwordTooltip}</ErrorTooltip>}>
|
||||
<ErrorWrapper data-testid="password-error-info">
|
||||
<ErrorIcon icon="question" height={14} />
|
||||
<Error name="password" component="div" />
|
||||
</ErrorWrapper>
|
||||
</WithTooltip>
|
||||
)}
|
||||
</FieldWrapper>
|
||||
{passwordVerification && (
|
||||
<FieldWrapper>
|
||||
<Label htmlFor="verifiedPassword">Verify Password</Label>
|
||||
<FormikInput id="verifiedPassword" name="verifiedPassword">
|
||||
{({ field }: { field: HTMLAttributes<HTMLInputElement> }) => (
|
||||
<Input
|
||||
data-testid="password2"
|
||||
aria-required="true"
|
||||
aria-disabled={isSubmitting ? 'true' : 'false'}
|
||||
aria-invalid={errors.verifiedPassword ? 'true' : 'false'}
|
||||
type="password"
|
||||
disabled={isSubmitting}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
</FormikInput>
|
||||
{errors.verifiedPassword && (
|
||||
<WithTooltip
|
||||
tooltip={<ErrorTooltip>{errors.verifiedPasswordTooltip}</ErrorTooltip>}
|
||||
>
|
||||
<ErrorWrapper>
|
||||
<ErrorIcon icon="question" height={14} />
|
||||
<Error name="verifiedPassword" component="div" />
|
||||
</ErrorWrapper>
|
||||
</WithTooltip>
|
||||
)}
|
||||
</FieldWrapper>
|
||||
)}
|
||||
<Actions>
|
||||
<Submit
|
||||
data-testid="submit"
|
||||
aria-disabled={isSubmitting || !dirty ? 'true' : 'false'}
|
||||
disabled={isSubmitting || !dirty}
|
||||
dirty={dirty}
|
||||
type="submit"
|
||||
>
|
||||
Create Account
|
||||
</Submit>
|
||||
<Reset
|
||||
aria-disabled={isSubmitting ? 'true' : 'false'}
|
||||
disabled={isSubmitting}
|
||||
type="reset"
|
||||
>
|
||||
Reset
|
||||
</Reset>
|
||||
</Actions>
|
||||
</Form>
|
||||
);
|
||||
}}
|
||||
</Formik>
|
||||
)}
|
||||
</Content>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
const Wrapper = styled.section(({ theme }) => ({
|
||||
fontFamily: theme.typography.fonts.base,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
width: 450,
|
||||
padding: 32,
|
||||
backgroundColor: theme.background.content,
|
||||
borderRadius: 7,
|
||||
}));
|
||||
|
||||
const Brand = styled.div({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
});
|
||||
|
||||
const Title = styled.svg({
|
||||
height: 40,
|
||||
zIndex: 1,
|
||||
left: -32,
|
||||
position: 'relative',
|
||||
});
|
||||
|
||||
const logoAnimation = keyframes({
|
||||
'0': {
|
||||
transform: 'rotateY(0deg)',
|
||||
transformOrigin: '50% 5% 0',
|
||||
},
|
||||
'100%': {
|
||||
transform: 'rotateY(360deg)',
|
||||
transformOrigin: '50% 5% 0',
|
||||
},
|
||||
});
|
||||
|
||||
interface LogoProps {
|
||||
transacting: boolean;
|
||||
}
|
||||
|
||||
const Logo = styled.svg<LogoProps>(
|
||||
({ transacting }) =>
|
||||
transacting && {
|
||||
animation: `${logoAnimation} 1250ms both infinite`,
|
||||
},
|
||||
{ height: 40, zIndex: 10, marginLeft: 32 }
|
||||
);
|
||||
|
||||
const Introduction = styled.p({
|
||||
marginTop: 20,
|
||||
textAlign: 'center',
|
||||
});
|
||||
|
||||
const Content = styled.div({
|
||||
display: 'flex',
|
||||
alignItems: 'flex-start',
|
||||
justifyContent: 'center',
|
||||
width: 350,
|
||||
minHeight: 189,
|
||||
marginTop: 8,
|
||||
});
|
||||
|
||||
const Presentation = styled.div({
|
||||
textAlign: 'center',
|
||||
});
|
||||
|
||||
const Form = styled(FormikForm)({
|
||||
width: '100%',
|
||||
alignSelf: 'flex-start',
|
||||
'&[aria-disabled="true"]': {
|
||||
opacity: 0.6,
|
||||
},
|
||||
});
|
||||
|
||||
const FieldWrapper = styled.div({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'stretch',
|
||||
marginBottom: 10,
|
||||
});
|
||||
|
||||
const Label = styled.label({
|
||||
fontSize: 13,
|
||||
fontWeight: 500,
|
||||
marginBottom: 6,
|
||||
});
|
||||
|
||||
const Input = styled.input(({ theme }) => ({
|
||||
fontSize: 14,
|
||||
color: theme.color.defaultText,
|
||||
padding: '10px 15px',
|
||||
borderRadius: 4,
|
||||
appearance: 'none',
|
||||
outline: 'none',
|
||||
border: '0 none',
|
||||
boxShadow: 'rgb(0 0 0 / 10%) 0px 0px 0px 1px inset',
|
||||
'&:focus': {
|
||||
boxShadow: 'rgb(30 167 253) 0px 0px 0px 1px inset',
|
||||
},
|
||||
'&:active': {
|
||||
boxShadow: 'rgb(30 167 253) 0px 0px 0px 1px inset',
|
||||
},
|
||||
'&[aria-invalid="true"]': {
|
||||
boxShadow: 'rgb(255 68 0) 0px 0px 0px 1px inset',
|
||||
},
|
||||
}));
|
||||
|
||||
const ErrorWrapper = styled.div({
|
||||
display: 'flex',
|
||||
alignItems: 'flex-start',
|
||||
fontSize: 11,
|
||||
marginTop: 6,
|
||||
cursor: 'help',
|
||||
});
|
||||
|
||||
const ErrorIcon = styled(Icons)(({ theme }) => ({
|
||||
fill: theme.color.defaultText,
|
||||
opacity: 0.8,
|
||||
marginRight: 6,
|
||||
marginLeft: 2,
|
||||
marginTop: 1,
|
||||
}));
|
||||
|
||||
const ErrorTooltip = styled.div(({ theme }) => ({
|
||||
fontFamily: theme.typography.fonts.base,
|
||||
fontSize: 13,
|
||||
padding: 8,
|
||||
maxWidth: 350,
|
||||
}));
|
||||
|
||||
const Actions = styled.div({
|
||||
alignSelf: 'stretch',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
marginTop: 24,
|
||||
});
|
||||
|
||||
const Error = styled(ErrorMessage)({});
|
||||
|
||||
interface ButtonProps {
|
||||
dirty?: boolean;
|
||||
}
|
||||
|
||||
const Button = styled.button<ButtonProps>({
|
||||
backgroundColor: 'transparent',
|
||||
border: '0 none',
|
||||
outline: 'none',
|
||||
appearance: 'none',
|
||||
fontWeight: 500,
|
||||
fontSize: 12,
|
||||
flexBasis: '50%',
|
||||
cursor: 'pointer',
|
||||
padding: '11px 16px',
|
||||
borderRadius: 4,
|
||||
textTransform: 'uppercase',
|
||||
'&:focus': {
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 700,
|
||||
},
|
||||
'&:active': {
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 700,
|
||||
},
|
||||
'&[aria-disabled="true"]': {
|
||||
cursor: 'default',
|
||||
},
|
||||
});
|
||||
|
||||
const Submit = styled(Button)(({ theme, dirty }) => ({
|
||||
marginRight: 8,
|
||||
backgroundColor: theme.color.secondary,
|
||||
color: theme.color.inverseText,
|
||||
opacity: dirty ? 1 : 0.6,
|
||||
boxShadow: 'rgb(30 167 253 / 10%) 0 0 0 1px inset',
|
||||
}));
|
||||
|
||||
const Reset = styled(Button)(({ theme }) => ({
|
||||
marginLeft: 8,
|
||||
boxShadow: 'rgb(30 167 253) 0 0 0 1px inset',
|
||||
color: theme.color.secondary,
|
||||
}));
|
@ -0,0 +1,86 @@
|
||||
import React from 'react';
|
||||
import type { StoryFn as CSF2Story, StoryObj as CSF3Story, Meta } from '@storybook/react';
|
||||
import { within, userEvent } from '@storybook/testing-library';
|
||||
|
||||
import { Button, ButtonProps } from './Button';
|
||||
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
label: { defaultValue: 'Button' },
|
||||
},
|
||||
} as Meta;
|
||||
|
||||
const Template: CSF2Story<ButtonProps> = (args) => <Button {...args} />;
|
||||
|
||||
export const CSF2Secondary = Template.bind({});
|
||||
CSF2Secondary.args = {
|
||||
children: 'Children coming from story args!',
|
||||
primary: false,
|
||||
};
|
||||
|
||||
const getCaptionForLocale = (locale: string) => {
|
||||
switch (locale) {
|
||||
case 'es':
|
||||
return 'Hola!';
|
||||
case 'fr':
|
||||
return 'Bonjour!';
|
||||
case 'kr':
|
||||
return '안녕하세요!';
|
||||
case 'pt':
|
||||
return 'Olá!';
|
||||
default:
|
||||
return 'Hello!';
|
||||
}
|
||||
};
|
||||
|
||||
export const CSF2StoryWithLocale: CSF2Story = (args, { globals: { locale } }) => {
|
||||
const caption = getCaptionForLocale(locale);
|
||||
return <Button>{caption}</Button>;
|
||||
};
|
||||
CSF2StoryWithLocale.storyName = 'WithLocale';
|
||||
|
||||
export const CSF2StoryWithParamsAndDecorator: CSF2Story<ButtonProps> = (args) => {
|
||||
return <Button {...args} />;
|
||||
};
|
||||
CSF2StoryWithParamsAndDecorator.args = {
|
||||
children: 'foo',
|
||||
};
|
||||
CSF2StoryWithParamsAndDecorator.parameters = {
|
||||
layout: 'centered',
|
||||
};
|
||||
CSF2StoryWithParamsAndDecorator.decorators = [(StoryFn) => <StoryFn />];
|
||||
|
||||
export const CSF3Primary: CSF3Story<ButtonProps> = {
|
||||
args: {
|
||||
children: 'foo',
|
||||
size: 'large',
|
||||
primary: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const CSF3Button: CSF3Story<ButtonProps> = {
|
||||
args: { children: 'foo' },
|
||||
};
|
||||
|
||||
export const CSF3ButtonWithRender: CSF3Story<ButtonProps> = {
|
||||
...CSF3Button,
|
||||
render: (args: any) => (
|
||||
<div>
|
||||
<p data-testid="custom-render">I am a custom render function</p>
|
||||
<Button {...args} />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const CSF3InputFieldFilled: CSF3Story = {
|
||||
render: () => {
|
||||
return <input data-testid="input" />;
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByTestId('input'), 'Hello world!');
|
||||
},
|
||||
};
|
@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { composeStories, composeStory } from '@storybook/react';
|
||||
|
||||
import * as stories from './Button.stories';
|
||||
|
||||
// example with composeStories, returns an object with all stories composed with args/decorators
|
||||
const { CSF3Primary } = composeStories(stories);
|
||||
|
||||
// example with composeStory, returns a single story composed with args/decorators
|
||||
const Secondary = composeStory(stories.CSF2Secondary, stories.default);
|
||||
|
||||
test('renders primary button', () => {
|
||||
render(<CSF3Primary>Hello world</CSF3Primary>);
|
||||
const buttonElement = screen.getByText(/Hello world/i);
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
|
||||
test('reuses args from composed story', () => {
|
||||
render(<Secondary />);
|
||||
|
||||
const buttonElement = screen.getByRole('button');
|
||||
expect(buttonElement.textContent).toEqual(Secondary.args.children);
|
||||
});
|
||||
|
||||
test('onclick handler is called', async () => {
|
||||
const onClickSpy = jest.fn();
|
||||
render(<Secondary onClick={onClickSpy} />);
|
||||
const buttonElement = screen.getByRole('button');
|
||||
buttonElement.click();
|
||||
expect(onClickSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('reuses args from composeStories', () => {
|
||||
const { getByText } = render(<CSF3Primary />);
|
||||
const buttonElement = getByText(/foo/i);
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
|
||||
describe('GlobalConfig', () => {
|
||||
test('renders with default globalConfig', () => {
|
||||
const WithEnglishText = composeStory(stories.CSF2StoryWithLocale, stories.default);
|
||||
const { getByText } = render(<WithEnglishText />);
|
||||
const buttonElement = getByText('Hello!');
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
|
||||
test('renders with custom globalConfig', () => {
|
||||
const WithPortugueseText = composeStory(stories.CSF2StoryWithLocale, stories.default, {
|
||||
globalTypes: { locale: { defaultValue: 'pt' } } as any,
|
||||
});
|
||||
const { getByText } = render(<WithPortugueseText />);
|
||||
const buttonElement = getByText('Olá!');
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('CSF3', () => {
|
||||
test('renders with inferred globalRender', () => {
|
||||
const Primary = composeStory(stories.CSF3Button, stories.default);
|
||||
|
||||
render(<Primary>Hello world</Primary>);
|
||||
const buttonElement = screen.getByText(/Hello world/i);
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
|
||||
test('renders with custom render function', () => {
|
||||
const Primary = composeStory(stories.CSF3ButtonWithRender, stories.default);
|
||||
|
||||
render(<Primary />);
|
||||
expect(screen.getByTestId('custom-render')).not.toBeNull();
|
||||
});
|
||||
|
||||
test('renders with play function', async () => {
|
||||
const CSF3InputFieldFilled = composeStory(stories.CSF3InputFieldFilled, stories.default);
|
||||
|
||||
const { container } = render(<CSF3InputFieldFilled />);
|
||||
|
||||
await CSF3InputFieldFilled.play({ canvasElement: container });
|
||||
|
||||
const input = screen.getByTestId('input') as HTMLInputElement;
|
||||
expect(input.value).toEqual('Hello world!');
|
||||
});
|
||||
});
|
@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import './button.css';
|
||||
|
||||
export interface ButtonProps {
|
||||
/**
|
||||
* Is this the principal call to action on the page?
|
||||
*/
|
||||
primary?: boolean;
|
||||
/**
|
||||
* What background color to use
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
/**
|
||||
* How large should the button be?
|
||||
*/
|
||||
size?: 'small' | 'medium' | 'large';
|
||||
/**
|
||||
* Button contents
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* Optional click handler
|
||||
*/
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary UI component for user interaction
|
||||
*/
|
||||
export const Button: React.FC<ButtonProps> = (props) => {
|
||||
const { primary = false, size = 'medium', backgroundColor, children, ...otherProps } = props;
|
||||
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
||||
style={{ backgroundColor }}
|
||||
{...otherProps}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
};
|
@ -0,0 +1,127 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Renders CSF2Secondary story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<button
|
||||
class="storybook-button storybook-button--medium storybook-button--secondary"
|
||||
label="Button"
|
||||
type="button"
|
||||
>
|
||||
Children coming from story args!
|
||||
</button>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF2StoryWithLocale story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<button
|
||||
class="storybook-button storybook-button--medium storybook-button--secondary"
|
||||
type="button"
|
||||
>
|
||||
Hello!
|
||||
</button>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF2StoryWithParamsAndDecorator story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<button
|
||||
class="storybook-button storybook-button--medium storybook-button--secondary"
|
||||
label="Button"
|
||||
type="button"
|
||||
>
|
||||
foo
|
||||
</button>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF3Button story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<button
|
||||
class="storybook-button storybook-button--medium storybook-button--secondary"
|
||||
label="Button"
|
||||
type="button"
|
||||
>
|
||||
foo
|
||||
</button>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF3ButtonWithRender story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
data-testid="custom-render"
|
||||
>
|
||||
I am a custom render function
|
||||
</p>
|
||||
<button
|
||||
class="storybook-button storybook-button--medium storybook-button--secondary"
|
||||
label="Button"
|
||||
type="button"
|
||||
>
|
||||
foo
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF3InputFieldFilled story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<input />
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`Renders CSF3Primary story 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
Locale:
|
||||
en
|
||||
</div>
|
||||
<button
|
||||
class="storybook-button storybook-button--large storybook-button--primary"
|
||||
label="Button"
|
||||
type="button"
|
||||
>
|
||||
foo
|
||||
</button>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
@ -0,0 +1,30 @@
|
||||
.storybook-button {
|
||||
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
font-weight: 700;
|
||||
border: 0;
|
||||
border-radius: 3em;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
line-height: 1;
|
||||
}
|
||||
.storybook-button--primary {
|
||||
color: white;
|
||||
background-color: #1ea7fd;
|
||||
}
|
||||
.storybook-button--secondary {
|
||||
color: #333;
|
||||
background-color: transparent;
|
||||
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
|
||||
}
|
||||
.storybook-button--small {
|
||||
font-size: 12px;
|
||||
padding: 10px 16px;
|
||||
}
|
||||
.storybook-button--medium {
|
||||
font-size: 14px;
|
||||
padding: 11px 20px;
|
||||
}
|
||||
.storybook-button--large {
|
||||
font-size: 16px;
|
||||
padding: 12px 24px;
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import React from 'react';
|
||||
import addons from '@storybook/addons';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { composeStories, composeStory } from '@storybook/react';
|
||||
|
||||
import * as stories from './Button.stories';
|
||||
|
||||
import * as globalConfig from '../../../../.storybook/preview';
|
||||
|
||||
const { CSF2StoryWithParamsAndDecorator } = composeStories(stories);
|
||||
|
||||
test('returns composed args including default values from argtypes', () => {
|
||||
expect(CSF2StoryWithParamsAndDecorator.args).toEqual({
|
||||
...stories.CSF2StoryWithParamsAndDecorator.args,
|
||||
label: stories.default.argTypes!.label!.defaultValue,
|
||||
});
|
||||
});
|
||||
|
||||
test('returns composed parameters from story', () => {
|
||||
expect(CSF2StoryWithParamsAndDecorator.parameters).toEqual(
|
||||
expect.objectContaining({
|
||||
...stories.CSF2StoryWithParamsAndDecorator.parameters,
|
||||
...globalConfig.parameters,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// common in addons that need to communicate between manager and preview
|
||||
test('should pass with decorators that need addons channel', () => {
|
||||
const PrimaryWithChannels = composeStory(stories.CSF3Primary, stories.default, {
|
||||
decorators: [
|
||||
(StoryFn: any) => {
|
||||
addons.getChannel();
|
||||
return <StoryFn />;
|
||||
},
|
||||
],
|
||||
});
|
||||
render(<PrimaryWithChannels>Hello world</PrimaryWithChannels>);
|
||||
const buttonElement = screen.getByText(/Hello world/i);
|
||||
expect(buttonElement).not.toBeNull();
|
||||
});
|
||||
|
||||
describe('Unsupported formats', () => {
|
||||
test('should throw error if story is undefined', () => {
|
||||
const UnsupportedStory = () => <div>hello world</div>;
|
||||
UnsupportedStory.story = { parameters: {} };
|
||||
|
||||
const UnsupportedStoryModule: any = {
|
||||
default: {},
|
||||
UnsupportedStory: undefined,
|
||||
};
|
||||
|
||||
expect(() => {
|
||||
composeStories(UnsupportedStoryModule);
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('non-story exports', () => {
|
||||
test('should filter non-story exports with excludeStories', () => {
|
||||
const StoryModuleWithNonStoryExports = {
|
||||
default: {
|
||||
title: 'Some/Component',
|
||||
excludeStories: /.*Data/,
|
||||
},
|
||||
LegitimateStory: () => <div>hello world</div>,
|
||||
mockData: {},
|
||||
};
|
||||
|
||||
const result = composeStories(StoryModuleWithNonStoryExports);
|
||||
expect(Object.keys(result)).not.toContain('mockData');
|
||||
});
|
||||
|
||||
test('should filter non-story exports with includeStories', () => {
|
||||
const StoryModuleWithNonStoryExports = {
|
||||
default: {
|
||||
title: 'Some/Component',
|
||||
includeStories: /.*Story/,
|
||||
},
|
||||
LegitimateStory: () => <div>hello world</div>,
|
||||
mockData: {},
|
||||
};
|
||||
|
||||
const result = composeStories(StoryModuleWithNonStoryExports);
|
||||
expect(Object.keys(result)).not.toContain('mockData');
|
||||
});
|
||||
});
|
||||
|
||||
// Batch snapshot testing
|
||||
const testCases = Object.values(composeStories(stories)).map((Story) => [
|
||||
// The ! is necessary in Typescript only, as the property is part of a partial type
|
||||
Story.storyName!,
|
||||
Story,
|
||||
]);
|
||||
test.each(testCases)('Renders %s story', async (_storyName, Story) => {
|
||||
const tree = await render(<Story />);
|
||||
expect(tree.baseElement).toMatchSnapshot();
|
||||
});
|
@ -6,7 +6,7 @@
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"jsx": "react",
|
||||
"module": "commonjs",
|
||||
"module": "esnext",
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
@ -18,9 +18,17 @@
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
]
|
||||
],
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
"@storybook/react": "6.5.0-alpha.52",
|
||||
"@storybook/theming": "6.5.0-alpha.52",
|
||||
"@testing-library/dom": "^7.31.2",
|
||||
"@testing-library/react": "12.1.2",
|
||||
"@testing-library/user-event": "^13.1.9",
|
||||
"@types/babel__preset-env": "^7",
|
||||
"@types/react": "^16.14.23",
|
||||
|
@ -1,11 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
/* eslint-disable storybook/await-interactions */
|
||||
/* eslint-disable storybook/use-storybook-testing-library */
|
||||
// @TODO: use addon-interactions and remove the rule disable above
|
||||
import React from 'react';
|
||||
import { ComponentStoryObj, ComponentMeta } from '@storybook/react';
|
||||
import { screen } from '@testing-library/dom';
|
||||
import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { AccountForm } from './AccountForm';
|
||||
import { AccountForm, AccountFormProps } from './AccountForm';
|
||||
|
||||
export default {
|
||||
// Title not needed due to CSF3 auto-title
|
||||
@ -20,17 +21,19 @@ export default {
|
||||
// Standard.args = { passwordVerification: false };
|
||||
// Standard.play = () => userEvent.type(screen.getByTestId('email'), 'michael@chromatic.com');
|
||||
|
||||
export const Standard: ComponentStoryObj<typeof AccountForm> = {
|
||||
type Story = ComponentStoryObj<typeof AccountForm>;
|
||||
|
||||
export const Standard: Story = {
|
||||
// render: (args: AccountFormProps) => <AccountForm {...args} />,
|
||||
args: { passwordVerification: false },
|
||||
};
|
||||
|
||||
export const StandardEmailFilled = {
|
||||
export const StandardEmailFilled: Story = {
|
||||
...Standard,
|
||||
play: () => userEvent.type(screen.getByTestId('email'), 'michael@chromatic.com'),
|
||||
};
|
||||
|
||||
export const StandardEmailFailed = {
|
||||
export const StandardEmailFailed: Story = {
|
||||
...Standard,
|
||||
play: async () => {
|
||||
await userEvent.type(screen.getByTestId('email'), 'michael@chromatic.com.com@com');
|
||||
@ -39,41 +42,41 @@ export const StandardEmailFailed = {
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardPasswordFailed = {
|
||||
export const StandardPasswordFailed: Story = {
|
||||
...Standard,
|
||||
play: async () => {
|
||||
await StandardEmailFilled.play();
|
||||
play: async (context) => {
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(screen.getByTestId('password1'), 'asdf');
|
||||
await userEvent.click(screen.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardFailHover = {
|
||||
export const StandardFailHover: Story = {
|
||||
...StandardPasswordFailed,
|
||||
play: async () => {
|
||||
await StandardPasswordFailed.play();
|
||||
play: async (context) => {
|
||||
await StandardPasswordFailed.play!(context);
|
||||
await sleep(100);
|
||||
await userEvent.hover(screen.getByTestId('password-error-info'));
|
||||
},
|
||||
};
|
||||
|
||||
export const Verification: ComponentStoryObj<typeof AccountForm> = {
|
||||
export const Verification: Story = {
|
||||
args: { passwordVerification: true },
|
||||
};
|
||||
|
||||
export const VerificationPasssword1 = {
|
||||
export const VerificationPasssword1: Story = {
|
||||
...Verification,
|
||||
play: async () => {
|
||||
await StandardEmailFilled.play();
|
||||
play: async (context) => {
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf');
|
||||
await userEvent.click(screen.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const VerificationPasswordMismatch = {
|
||||
export const VerificationPasswordMismatch: Story = {
|
||||
...Verification,
|
||||
play: async () => {
|
||||
await StandardEmailFilled.play();
|
||||
play: async (context) => {
|
||||
await StandardEmailFilled.play!(context);
|
||||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf');
|
||||
await userEvent.type(screen.getByTestId('password2'), 'asdf1234');
|
||||
await userEvent.click(screen.getByTestId('submit'));
|
||||
@ -82,10 +85,10 @@ export const VerificationPasswordMismatch = {
|
||||
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
export const VerificationSuccess = {
|
||||
export const VerificationSuccess: Story = {
|
||||
...Verification,
|
||||
play: async () => {
|
||||
await StandardEmailFilled.play();
|
||||
play: async (context) => {
|
||||
await StandardEmailFilled.play!(context);
|
||||
await sleep(1000);
|
||||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf', { delay: 50 });
|
||||
await sleep(1000);
|
||||
@ -94,3 +97,13 @@ export const VerificationSuccess = {
|
||||
await userEvent.click(screen.getByTestId('submit'));
|
||||
},
|
||||
};
|
||||
|
||||
export const StandardWithRenderFunction: Story = {
|
||||
...Standard,
|
||||
render: (args: AccountFormProps) => (
|
||||
<div>
|
||||
<p>This uses a custom render</p>
|
||||
<AccountForm {...args} />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
@ -1840,6 +1840,379 @@ exports[`Storyshots Demo/AccountForm Standard Password Failed 1`] = `
|
||||
</section>
|
||||
`;
|
||||
|
||||
exports[`Storyshots Demo/AccountForm Standard With Render Function 1`] = `
|
||||
.emotion-15 {
|
||||
font-family: "Nunito Sans",-apple-system,".SFNSText-Regular","San Francisco",BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-flex-direction: column;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
width: 450px;
|
||||
padding: 32px;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
height: 40px;
|
||||
z-index: 10;
|
||||
margin-left: 32px;
|
||||
}
|
||||
|
||||
.emotion-1 {
|
||||
height: 40px;
|
||||
z-index: 1;
|
||||
left: -32px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.emotion-3 {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.emotion-14 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: flex-start;
|
||||
-webkit-box-align: flex-start;
|
||||
-ms-flex-align: flex-start;
|
||||
align-items: flex-start;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
width: 350px;
|
||||
min-height: 189px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.emotion-13 {
|
||||
width: 100%;
|
||||
-webkit-align-self: flex-start;
|
||||
-ms-flex-item-align: start;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.emotion-13[aria-disabled="true"] {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.emotion-6 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-flex-direction: column;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
-webkit-box-pack: stretch;
|
||||
-webkit-justify-content: stretch;
|
||||
-ms-flex-pack: stretch;
|
||||
justify-content: stretch;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.emotion-4 {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.emotion-5 {
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
padding: 10px 15px;
|
||||
border-radius: 4px;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
outline: none;
|
||||
border: 0 none;
|
||||
box-shadow: rgb(0 0 0 / 10%) 0px 0px 0px 1px inset;
|
||||
}
|
||||
|
||||
.emotion-5:focus {
|
||||
box-shadow: rgb(30 167 253) 0px 0px 0px 1px inset;
|
||||
}
|
||||
|
||||
.emotion-5:active {
|
||||
box-shadow: rgb(30 167 253) 0px 0px 0px 1px inset;
|
||||
}
|
||||
|
||||
.emotion-5[aria-invalid="true"] {
|
||||
box-shadow: rgb(255 68 0) 0px 0px 0px 1px inset;
|
||||
}
|
||||
|
||||
.emotion-12 {
|
||||
-webkit-align-self: stretch;
|
||||
-ms-flex-item-align: stretch;
|
||||
align-self: stretch;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.emotion-10 {
|
||||
background-color: transparent;
|
||||
border: 0 none;
|
||||
outline: none;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
-webkit-flex-basis: 50%;
|
||||
-ms-flex-preferred-size: 50%;
|
||||
flex-basis: 50%;
|
||||
cursor: pointer;
|
||||
padding: 11px 16px;
|
||||
border-radius: 4px;
|
||||
text-transform: uppercase;
|
||||
margin-right: 8px;
|
||||
background-color: #1EA7FD;
|
||||
color: #FFFFFF;
|
||||
opacity: 0.6;
|
||||
box-shadow: rgb(30 167 253 / 10%) 0 0 0 1px inset;
|
||||
}
|
||||
|
||||
.emotion-10:focus {
|
||||
-webkit-text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.emotion-10:active {
|
||||
-webkit-text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.emotion-10[aria-disabled="true"] {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.emotion-11 {
|
||||
background-color: transparent;
|
||||
border: 0 none;
|
||||
outline: none;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
-webkit-flex-basis: 50%;
|
||||
-ms-flex-preferred-size: 50%;
|
||||
flex-basis: 50%;
|
||||
cursor: pointer;
|
||||
padding: 11px 16px;
|
||||
border-radius: 4px;
|
||||
text-transform: uppercase;
|
||||
margin-left: 8px;
|
||||
box-shadow: rgb(30 167 253) 0 0 0 1px inset;
|
||||
color: #1EA7FD;
|
||||
}
|
||||
|
||||
.emotion-11:focus {
|
||||
-webkit-text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.emotion-11:active {
|
||||
-webkit-text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.emotion-11[aria-disabled="true"] {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
<div>
|
||||
<p>
|
||||
This uses a custom render
|
||||
</p>
|
||||
<section
|
||||
className="emotion-15"
|
||||
>
|
||||
<div
|
||||
className="emotion-2"
|
||||
>
|
||||
<svg
|
||||
aria-label="Storybook Logo"
|
||||
className="emotion-0"
|
||||
role="img"
|
||||
viewBox="0 0 64 64"
|
||||
>
|
||||
<title>
|
||||
Storybook icon
|
||||
</title>
|
||||
<g
|
||||
fill="none"
|
||||
fillRule="evenodd"
|
||||
id="Artboard"
|
||||
stroke="none"
|
||||
strokeWidth="1"
|
||||
>
|
||||
<path
|
||||
d="M8.04798541,58.7875918 L6.07908839,6.32540407 C6.01406344,4.5927838 7.34257463,3.12440831 9.07303814,3.01625434 L53.6958037,0.227331489 C55.457209,0.117243658 56.974354,1.45590096 57.0844418,3.21730626 C57.0885895,3.28366922 57.0906648,3.35014546 57.0906648,3.41663791 L57.0906648,60.5834697 C57.0906648,62.3483119 55.6599776,63.7789992 53.8951354,63.7789992 C53.847325,63.7789992 53.7995207,63.7779262 53.7517585,63.775781 L11.0978899,61.8600599 C9.43669044,61.7854501 8.11034889,60.4492961 8.04798541,58.7875918 Z"
|
||||
fill="#FF4785"
|
||||
fillRule="nonzero"
|
||||
id="path-1"
|
||||
/>
|
||||
<path
|
||||
d="M35.9095005,24.1768792 C35.9095005,25.420127 44.2838488,24.8242707 45.4080313,23.9509748 C45.4080313,15.4847538 40.8652557,11.0358878 32.5466666,11.0358878 C24.2280775,11.0358878 19.5673077,15.553972 19.5673077,22.3311017 C19.5673077,34.1346028 35.4965208,34.3605071 35.4965208,40.7987804 C35.4965208,42.606015 34.6115646,43.6790606 32.6646607,43.6790606 C30.127786,43.6790606 29.1248356,42.3834613 29.2428298,37.9783269 C29.2428298,37.0226907 19.5673077,36.7247626 19.2723223,37.9783269 C18.5211693,48.6535354 25.1720308,51.7326752 32.7826549,51.7326752 C40.1572906,51.7326752 45.939005,47.8018145 45.939005,40.6858282 C45.939005,28.035186 29.7738035,28.3740425 29.7738035,22.1051974 C29.7738035,19.5637737 31.6617103,19.2249173 32.7826549,19.2249173 C33.9625966,19.2249173 36.0864917,19.4328883 35.9095005,24.1768792 Z"
|
||||
fill="#FFFFFF"
|
||||
fillRule="nonzero"
|
||||
id="path9_fill-path"
|
||||
/>
|
||||
<path
|
||||
d="M44.0461638,0.830433986 L50.1874092,0.446606143 L50.443532,7.7810017 C50.4527198,8.04410717 50.2468789,8.26484453 49.9837734,8.27403237 C49.871115,8.27796649 49.7607078,8.24184808 49.6721567,8.17209069 L47.3089847,6.3104681 L44.5110468,8.43287463 C44.3012992,8.591981 44.0022839,8.55092814 43.8431776,8.34118051 C43.7762017,8.25288717 43.742082,8.14401677 43.7466857,8.03329059 L44.0461638,0.830433986 Z"
|
||||
fill="#FFFFFF"
|
||||
id="Path"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
<svg
|
||||
aria-label="Storybook"
|
||||
className="emotion-1"
|
||||
role="img"
|
||||
viewBox="0 0 200 40"
|
||||
>
|
||||
<title>
|
||||
Storybook
|
||||
</title>
|
||||
<g
|
||||
fill="none"
|
||||
fillRule="evenodd"
|
||||
>
|
||||
<path
|
||||
d="M53.3 31.7c-1.7 0-3.4-.3-5-.7-1.5-.5-2.8-1.1-3.9-2l1.6-3.5c2.2 1.5 4.6 2.3 7.3 2.3 1.5 0 2.5-.2 3.3-.7.7-.5 1.1-1 1.1-1.9 0-.7-.3-1.3-1-1.7s-2-.8-3.7-1.2c-2-.4-3.6-.9-4.8-1.5-1.1-.5-2-1.2-2.6-2-.5-1-.8-2-.8-3.2 0-1.4.4-2.6 1.2-3.6.7-1.1 1.8-2 3.2-2.6 1.3-.6 2.9-.9 4.7-.9 1.6 0 3.1.3 4.6.7 1.5.5 2.7 1.1 3.5 2l-1.6 3.5c-2-1.5-4.2-2.3-6.5-2.3-1.3 0-2.3.2-3 .8-.8.5-1.2 1.1-1.2 2 0 .5.2 1 .5 1.3.2.3.7.6 1.4.9l2.9.8c2.9.6 5 1.4 6.2 2.4a5 5 0 0 1 2 4.2 6 6 0 0 1-2.5 5c-1.7 1.2-4 1.9-7 1.9zm21-3.6l1.4-.1-.2 3.5-1.9.1c-2.4 0-4.1-.5-5.2-1.5-1.1-1-1.6-2.7-1.6-4.8v-6h-3v-3.6h3V11h4.8v4.6h4v3.6h-4v6c0 1.8.9 2.8 2.6 2.8zm11.1 3.5c-1.6 0-3-.3-4.3-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.3-1 1.7 0 3.2.3 4.4 1a7 7 0 0 1 3 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.4 1zm0-3.6c2.4 0 3.6-1.6 3.6-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.6-1c-2.3 0-3.5 1.4-3.5 4.4 0 3 1.2 4.6 3.5 4.6zm21.7-8.8l-2.7.3c-1.3.2-2.3.5-2.8 1.2-.6.6-.9 1.4-.9 2.5v8.2H96V15.7h4.6v2.6c.8-1.8 2.5-2.8 5-3h1.3l.3 4zm14-3.5h4.8L116.4 37h-4.9l3-6.6-6.4-14.8h5l4 10 4-10zm16-.4c1.4 0 2.6.3 3.6 1 1 .6 1.9 1.6 2.5 2.8.6 1.2.9 2.7.9 4.3 0 1.6-.3 3-1 4.3a6.9 6.9 0 0 1-2.4 2.9c-1 .7-2.2 1-3.6 1-1 0-2-.2-3-.7-.8-.4-1.5-1-2-1.9v2.4h-4.7V8.8h4.8v9c.5-.8 1.2-1.4 2-1.9.9-.4 1.8-.6 3-.6zM135.7 28c1.1 0 2-.4 2.6-1.2.6-.8 1-2 1-3.4 0-1.5-.4-2.5-1-3.3s-1.5-1.1-2.6-1.1-2 .3-2.6 1.1c-.6.8-1 2-1 3.3 0 1.5.4 2.6 1 3.4.6.8 1.5 1.2 2.6 1.2zm18.9 3.6c-1.7 0-3.2-.3-4.4-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.4-1 1.6 0 3 .3 4.3 1a7 7 0 0 1 3 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.3 1zm0-3.6c2.3 0 3.5-1.6 3.5-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.5-1c-2.4 0-3.6 1.4-3.6 4.4 0 3 1.2 4.6 3.6 4.6zm18 3.6c-1.7 0-3.2-.3-4.4-1a7 7 0 0 1-3-2.8c-.6-1.3-1-2.7-1-4.4 0-1.6.4-3 1-4.3a7 7 0 0 1 3-2.8c1.2-.7 2.7-1 4.4-1 1.6 0 3 .3 4.4 1a7 7 0 0 1 2.9 2.8c.6 1.2 1 2.7 1 4.3 0 1.7-.4 3.1-1 4.4a7 7 0 0 1-3 2.8c-1.2.7-2.7 1-4.3 1zm0-3.6c2.3 0 3.5-1.6 3.5-4.6 0-1.5-.3-2.6-1-3.4a3.2 3.2 0 0 0-2.5-1c-2.4 0-3.6 1.4-3.6 4.4 0 3 1.2 4.6 3.6 4.6zm27.4 3.4h-6l-6-7v7h-4.8V8.8h4.9v13.6l5.8-6.7h5.7l-6.6 7.5 7 8.2z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<p
|
||||
className="emotion-3"
|
||||
>
|
||||
Create an account to join the Storybook community
|
||||
</p>
|
||||
<div
|
||||
className="emotion-14"
|
||||
>
|
||||
<form
|
||||
action="#"
|
||||
aria-disabled="false"
|
||||
className="emotion-13"
|
||||
noValidate={true}
|
||||
onReset={[Function]}
|
||||
onSubmit={[Function]}
|
||||
>
|
||||
<div
|
||||
className="emotion-6"
|
||||
>
|
||||
<label
|
||||
className="emotion-4"
|
||||
htmlFor="email"
|
||||
>
|
||||
Email
|
||||
</label>
|
||||
<input
|
||||
aria-disabled="false"
|
||||
aria-invalid="false"
|
||||
aria-required="true"
|
||||
className="emotion-5"
|
||||
data-testid="email"
|
||||
disabled={false}
|
||||
name="email"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
type="email"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="emotion-6"
|
||||
>
|
||||
<label
|
||||
className="emotion-4"
|
||||
htmlFor="password"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
aria-disabled="false"
|
||||
aria-invalid="false"
|
||||
aria-required="true"
|
||||
className="emotion-5"
|
||||
data-testid="password1"
|
||||
disabled={false}
|
||||
name="password"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
type="password"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="emotion-12"
|
||||
>
|
||||
<button
|
||||
aria-disabled="true"
|
||||
className="emotion-10"
|
||||
data-testid="submit"
|
||||
disabled={true}
|
||||
type="submit"
|
||||
>
|
||||
Create Account
|
||||
</button>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
className="emotion-11"
|
||||
disabled={false}
|
||||
type="reset"
|
||||
>
|
||||
Reset
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Storyshots Demo/AccountForm Verification 1`] = `
|
||||
.emotion-18 {
|
||||
font-family: "Nunito Sans",-apple-system,".SFNSText-Regular","San Francisco",BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import global from 'global';
|
||||
|
||||
import { composeConfigs, PreviewWeb } from '@storybook/preview-web';
|
||||
import { PreviewWeb } from '@storybook/preview-web';
|
||||
import { composeConfigs } from '@storybook/store';
|
||||
import { ClientApi } from '@storybook/client-api';
|
||||
import { addons } from '@storybook/addons';
|
||||
import createPostMessageChannel from '@storybook/channel-postmessage';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import global from 'global';
|
||||
|
||||
import { composeConfigs, PreviewWeb } from '@storybook/preview-web';
|
||||
import { PreviewWeb } from '@storybook/preview-web';
|
||||
import { composeConfigs } from '@storybook/store';
|
||||
import { ClientApi } from '@storybook/client-api';
|
||||
import { addons } from '@storybook/addons';
|
||||
import createPostMessageChannel from '@storybook/channel-postmessage';
|
||||
|
@ -1,59 +1,59 @@
|
||||
// auto generated file, do not edit
|
||||
export default {
|
||||
"@storybook/addon-a11y": "6.5.0-alpha.52",
|
||||
"@storybook/addon-actions": "6.5.0-alpha.52",
|
||||
"@storybook/addon-backgrounds": "6.5.0-alpha.52",
|
||||
"@storybook/addon-controls": "6.5.0-alpha.52",
|
||||
"@storybook/addon-docs": "6.5.0-alpha.52",
|
||||
"@storybook/addon-essentials": "6.5.0-alpha.52",
|
||||
"@storybook/addon-interactions": "6.5.0-alpha.52",
|
||||
"@storybook/addon-jest": "6.5.0-alpha.52",
|
||||
"@storybook/addon-links": "6.5.0-alpha.52",
|
||||
"@storybook/addon-measure": "6.5.0-alpha.52",
|
||||
"@storybook/addon-outline": "6.5.0-alpha.52",
|
||||
"@storybook/addon-storyshots": "6.5.0-alpha.52",
|
||||
"@storybook/addon-storyshots-puppeteer": "6.5.0-alpha.52",
|
||||
"@storybook/addon-storysource": "6.5.0-alpha.52",
|
||||
"@storybook/addon-toolbars": "6.5.0-alpha.52",
|
||||
"@storybook/addon-viewport": "6.5.0-alpha.52",
|
||||
"@storybook/addons": "6.5.0-alpha.52",
|
||||
"@storybook/angular": "6.5.0-alpha.52",
|
||||
"@storybook/api": "6.5.0-alpha.52",
|
||||
"@storybook/builder-webpack4": "6.5.0-alpha.52",
|
||||
"@storybook/builder-webpack5": "6.5.0-alpha.52",
|
||||
"@storybook/channel-postmessage": "6.5.0-alpha.52",
|
||||
"@storybook/channel-websocket": "6.5.0-alpha.52",
|
||||
"@storybook/channels": "6.5.0-alpha.52",
|
||||
"@storybook/cli": "6.5.0-alpha.52",
|
||||
"@storybook/client-api": "6.5.0-alpha.52",
|
||||
"@storybook/client-logger": "6.5.0-alpha.52",
|
||||
"@storybook/codemod": "6.5.0-alpha.52",
|
||||
"@storybook/components": "6.5.0-alpha.52",
|
||||
"@storybook/core": "6.5.0-alpha.52",
|
||||
"@storybook/core-client": "6.5.0-alpha.52",
|
||||
"@storybook/core-common": "6.5.0-alpha.52",
|
||||
"@storybook/core-events": "6.5.0-alpha.52",
|
||||
"@storybook/core-server": "6.5.0-alpha.52",
|
||||
"@storybook/csf-tools": "6.5.0-alpha.52",
|
||||
"@storybook/docs-tools": "6.5.0-alpha.52",
|
||||
"@storybook/ember": "6.5.0-alpha.52",
|
||||
"@storybook/html": "6.5.0-alpha.52",
|
||||
"@storybook/instrumenter": "6.5.0-alpha.52",
|
||||
"@storybook/manager-webpack4": "6.5.0-alpha.52",
|
||||
"@storybook/manager-webpack5": "6.5.0-alpha.52",
|
||||
"@storybook/node-logger": "6.5.0-alpha.52",
|
||||
"@storybook/postinstall": "6.5.0-alpha.52",
|
||||
"@storybook/preact": "6.5.0-alpha.52",
|
||||
"@storybook/preview-web": "6.5.0-alpha.52",
|
||||
"@storybook/react": "6.5.0-alpha.52",
|
||||
"@storybook/router": "6.5.0-alpha.52",
|
||||
"@storybook/server": "6.5.0-alpha.52",
|
||||
"@storybook/source-loader": "6.5.0-alpha.52",
|
||||
"@storybook/store": "6.5.0-alpha.52",
|
||||
"@storybook/svelte": "6.5.0-alpha.52",
|
||||
"@storybook/theming": "6.5.0-alpha.52",
|
||||
"@storybook/ui": "6.5.0-alpha.52",
|
||||
"@storybook/vue": "6.5.0-alpha.52",
|
||||
"@storybook/vue3": "6.5.0-alpha.52",
|
||||
"@storybook/web-components": "6.5.0-alpha.52"
|
||||
}
|
||||
'@storybook/addon-a11y': '6.5.0-alpha.52',
|
||||
'@storybook/addon-actions': '6.5.0-alpha.52',
|
||||
'@storybook/addon-backgrounds': '6.5.0-alpha.52',
|
||||
'@storybook/addon-controls': '6.5.0-alpha.52',
|
||||
'@storybook/addon-docs': '6.5.0-alpha.52',
|
||||
'@storybook/addon-essentials': '6.5.0-alpha.52',
|
||||
'@storybook/addon-interactions': '6.5.0-alpha.52',
|
||||
'@storybook/addon-jest': '6.5.0-alpha.52',
|
||||
'@storybook/addon-links': '6.5.0-alpha.52',
|
||||
'@storybook/addon-measure': '6.5.0-alpha.52',
|
||||
'@storybook/addon-outline': '6.5.0-alpha.52',
|
||||
'@storybook/addon-storyshots': '6.5.0-alpha.52',
|
||||
'@storybook/addon-storyshots-puppeteer': '6.5.0-alpha.52',
|
||||
'@storybook/addon-storysource': '6.5.0-alpha.52',
|
||||
'@storybook/addon-toolbars': '6.5.0-alpha.52',
|
||||
'@storybook/addon-viewport': '6.5.0-alpha.52',
|
||||
'@storybook/addons': '6.5.0-alpha.52',
|
||||
'@storybook/angular': '6.5.0-alpha.52',
|
||||
'@storybook/api': '6.5.0-alpha.52',
|
||||
'@storybook/builder-webpack4': '6.5.0-alpha.52',
|
||||
'@storybook/builder-webpack5': '6.5.0-alpha.52',
|
||||
'@storybook/channel-postmessage': '6.5.0-alpha.52',
|
||||
'@storybook/channel-websocket': '6.5.0-alpha.52',
|
||||
'@storybook/channels': '6.5.0-alpha.52',
|
||||
'@storybook/cli': '6.5.0-alpha.52',
|
||||
'@storybook/client-api': '6.5.0-alpha.52',
|
||||
'@storybook/client-logger': '6.5.0-alpha.52',
|
||||
'@storybook/codemod': '6.5.0-alpha.52',
|
||||
'@storybook/components': '6.5.0-alpha.52',
|
||||
'@storybook/core': '6.5.0-alpha.52',
|
||||
'@storybook/core-client': '6.5.0-alpha.52',
|
||||
'@storybook/core-common': '6.5.0-alpha.52',
|
||||
'@storybook/core-events': '6.5.0-alpha.52',
|
||||
'@storybook/core-server': '6.5.0-alpha.52',
|
||||
'@storybook/csf-tools': '6.5.0-alpha.52',
|
||||
'@storybook/docs-tools': '6.5.0-alpha.52',
|
||||
'@storybook/ember': '6.5.0-alpha.52',
|
||||
'@storybook/html': '6.5.0-alpha.52',
|
||||
'@storybook/instrumenter': '6.5.0-alpha.52',
|
||||
'@storybook/manager-webpack4': '6.5.0-alpha.52',
|
||||
'@storybook/manager-webpack5': '6.5.0-alpha.52',
|
||||
'@storybook/node-logger': '6.5.0-alpha.52',
|
||||
'@storybook/postinstall': '6.5.0-alpha.52',
|
||||
'@storybook/preact': '6.5.0-alpha.52',
|
||||
'@storybook/preview-web': '6.5.0-alpha.52',
|
||||
'@storybook/react': '6.5.0-alpha.52',
|
||||
'@storybook/router': '6.5.0-alpha.52',
|
||||
'@storybook/server': '6.5.0-alpha.52',
|
||||
'@storybook/source-loader': '6.5.0-alpha.52',
|
||||
'@storybook/store': '6.5.0-alpha.52',
|
||||
'@storybook/svelte': '6.5.0-alpha.52',
|
||||
'@storybook/theming': '6.5.0-alpha.52',
|
||||
'@storybook/ui': '6.5.0-alpha.52',
|
||||
'@storybook/vue': '6.5.0-alpha.52',
|
||||
'@storybook/vue3': '6.5.0-alpha.52',
|
||||
'@storybook/web-components': '6.5.0-alpha.52',
|
||||
};
|
||||
|
@ -2,12 +2,11 @@ import global from 'global';
|
||||
import deprecate from 'util-deprecate';
|
||||
import { ClientApi } from '@storybook/client-api';
|
||||
import { PreviewWeb } from '@storybook/preview-web';
|
||||
import type { WebProjectAnnotations } from '@storybook/preview-web';
|
||||
import type { AnyFramework, ArgsStoryFn } from '@storybook/csf';
|
||||
import createChannel from '@storybook/channel-postmessage';
|
||||
import { addons } from '@storybook/addons';
|
||||
import Events from '@storybook/core-events';
|
||||
import type { Path } from '@storybook/store';
|
||||
import type { Path, WebProjectAnnotations } from '@storybook/store';
|
||||
|
||||
import { Loadable } from './types';
|
||||
import { executeLoadableForChanges } from './executeLoadable';
|
||||
|
@ -17,7 +17,7 @@ Object {
|
||||
"ROOT/addons/backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js",
|
||||
"ROOT/addons/measure/dist/esm/preset/addDecorator.js-generated-config-entry.js",
|
||||
"ROOT/addons/outline/dist/esm/preset/addDecorator.js-generated-config-entry.js",
|
||||
"ROOT/examples/cra-ts-essentials/.storybook/preview.js-generated-config-entry.js",
|
||||
"ROOT/examples/cra-ts-essentials/.storybook/preview.tsx-generated-config-entry.js",
|
||||
"ROOT/generated-stories-entry.js",
|
||||
],
|
||||
"keys": Array [
|
||||
|
@ -16,7 +16,7 @@ Object {
|
||||
"ROOT/addons/backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js",
|
||||
"ROOT/addons/measure/dist/esm/preset/addDecorator.js-generated-config-entry.js",
|
||||
"ROOT/addons/outline/dist/esm/preset/addDecorator.js-generated-config-entry.js",
|
||||
"ROOT/examples/cra-ts-essentials/.storybook/preview.js-generated-config-entry.js",
|
||||
"ROOT/examples/cra-ts-essentials/.storybook/preview.tsx-generated-config-entry.js",
|
||||
"ROOT/generated-stories-entry.js",
|
||||
],
|
||||
"keys": Array [
|
||||
|
@ -5,7 +5,7 @@ import Events, { IGNORED_EXCEPTION } from '@storybook/core-events';
|
||||
import { logger } from '@storybook/client-logger';
|
||||
import { addons, mockChannel as createMockChannel } from '@storybook/addons';
|
||||
import type { AnyFramework } from '@storybook/csf';
|
||||
import type { ModuleImportFn } from '@storybook/store';
|
||||
import type { ModuleImportFn, WebProjectAnnotations } from '@storybook/store';
|
||||
|
||||
import { PreviewWeb } from './PreviewWeb';
|
||||
import {
|
||||
@ -22,7 +22,6 @@ import {
|
||||
waitForQuiescence,
|
||||
waitForRenderPhase,
|
||||
} from './PreviewWeb.mockdata';
|
||||
import type { WebProjectAnnotations } from './types';
|
||||
|
||||
jest.mock('./WebView');
|
||||
const { history, document } = global;
|
||||
|
@ -13,10 +13,9 @@ import {
|
||||
StoryStore,
|
||||
StorySpecifier,
|
||||
StoryIndex,
|
||||
WebProjectAnnotations,
|
||||
} from '@storybook/store';
|
||||
|
||||
import { WebProjectAnnotations } from './types';
|
||||
|
||||
import { UrlStore } from './UrlStore';
|
||||
import { WebView } from './WebView';
|
||||
import { PREPARE_ABORTED, StoryRender } from './StoryRender';
|
||||
|
@ -1,6 +1,5 @@
|
||||
export { PreviewWeb } from './PreviewWeb';
|
||||
|
||||
export { composeConfigs } from './composeConfigs';
|
||||
export { simulatePageLoad, simulateDOMContentLoaded } from './simulate-pageload';
|
||||
|
||||
export * from './types';
|
||||
|
@ -2,20 +2,14 @@ import type {
|
||||
StoryId,
|
||||
StoryName,
|
||||
AnyFramework,
|
||||
ProjectAnnotations,
|
||||
StoryContextForLoaders,
|
||||
ComponentTitle,
|
||||
Args,
|
||||
Globals,
|
||||
} from '@storybook/csf';
|
||||
import type { RenderContext, Story } from '@storybook/store';
|
||||
import type { Story } from '@storybook/store';
|
||||
import { PreviewWeb } from './PreviewWeb';
|
||||
|
||||
export type WebProjectAnnotations<TFramework extends AnyFramework> =
|
||||
ProjectAnnotations<TFramework> & {
|
||||
renderToDOM?: (context: RenderContext<TFramework>, element: Element) => Promise<void> | void;
|
||||
};
|
||||
|
||||
export interface DocsContextProps<TFramework extends AnyFramework = AnyFramework> {
|
||||
id: StoryId;
|
||||
title: ComponentTitle;
|
||||
|
@ -1,21 +1,19 @@
|
||||
import type { AnyFramework, ProjectAnnotations } from '@storybook/csf';
|
||||
import global from 'global';
|
||||
|
||||
import { prepareStory, processCSFFile } from './csf';
|
||||
import { prepareStory } from './csf/prepareStory';
|
||||
import { processCSFFile } from './csf/processCSFFile';
|
||||
import { StoryStore } from './StoryStore';
|
||||
import type { StoryIndex } from './types';
|
||||
import { HooksContext } from './hooks';
|
||||
|
||||
// Spy on prepareStory/processCSFFile
|
||||
jest.mock('./csf', () => {
|
||||
const actualModule = jest.requireActual('./csf');
|
||||
|
||||
return {
|
||||
...actualModule,
|
||||
prepareStory: jest.fn(actualModule.prepareStory),
|
||||
processCSFFile: jest.fn(actualModule.processCSFFile),
|
||||
};
|
||||
});
|
||||
jest.mock('./csf/prepareStory', () => ({
|
||||
prepareStory: jest.fn(jest.requireActual('./csf/prepareStory').prepareStory),
|
||||
}));
|
||||
jest.mock('./csf/processCSFFile', () => ({
|
||||
processCSFFile: jest.fn(jest.requireActual('./csf/processCSFFile').processCSFFile),
|
||||
}));
|
||||
|
||||
jest.mock('global', () => ({
|
||||
...(jest.requireActual('global') as any),
|
||||
|
@ -1,21 +1,33 @@
|
||||
import type { AnyFramework } from '@storybook/csf';
|
||||
import { combineParameters } from '@storybook/store';
|
||||
import type { ModuleExports } from '@storybook/store';
|
||||
import type { WebProjectAnnotations } from './types';
|
||||
|
||||
function getField(moduleExportList: ModuleExports[], field: string): any[] {
|
||||
import { combineParameters } from '../parameters';
|
||||
import type { ModuleExports, WebProjectAnnotations } from '../types';
|
||||
|
||||
export function getField<TFieldType = any>(
|
||||
moduleExportList: ModuleExports[],
|
||||
field: string
|
||||
): TFieldType | TFieldType[] {
|
||||
return moduleExportList.map((xs) => xs[field]).filter(Boolean);
|
||||
}
|
||||
|
||||
function getArrayField(moduleExportList: ModuleExports[], field: string): any[] {
|
||||
return getField(moduleExportList, field).reduce((a, b) => [...a, ...b], []);
|
||||
export function getArrayField<TFieldType = any>(
|
||||
moduleExportList: ModuleExports[],
|
||||
field: string
|
||||
): TFieldType[] {
|
||||
return getField(moduleExportList, field).reduce((a: any, b: any) => [...a, ...b], []);
|
||||
}
|
||||
|
||||
function getObjectField(moduleExportList: ModuleExports[], field: string): Record<string, any> {
|
||||
export function getObjectField<TFieldType = Record<string, any>>(
|
||||
moduleExportList: ModuleExports[],
|
||||
field: string
|
||||
): TFieldType {
|
||||
return Object.assign({}, ...getField(moduleExportList, field));
|
||||
}
|
||||
|
||||
function getSingletonField(moduleExportList: ModuleExports[], field: string): any {
|
||||
export function getSingletonField<TFieldType = any>(
|
||||
moduleExportList: ModuleExports[],
|
||||
field: string
|
||||
): TFieldType {
|
||||
return getField(moduleExportList, field).pop();
|
||||
}
|
||||
|
@ -5,3 +5,5 @@ export * from './prepareStory';
|
||||
export * from './normalizeComponentAnnotations';
|
||||
export * from './normalizeProjectAnnotations';
|
||||
export * from './getValuesFromArgTypes';
|
||||
export * from './composeConfigs';
|
||||
export * from './testing-utils';
|
||||
|
77
lib/store/src/csf/testing-utils/index.test.ts
Normal file
77
lib/store/src/csf/testing-utils/index.test.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import { composeStory, composeStories } from './index';
|
||||
|
||||
// Most integration tests for this functionality are located under examples/cra-ts-essentials
|
||||
describe('composeStory', () => {
|
||||
const meta = {
|
||||
title: 'Button',
|
||||
parameters: {
|
||||
firstAddon: true,
|
||||
},
|
||||
args: {
|
||||
label: 'Hello World',
|
||||
primary: true,
|
||||
},
|
||||
};
|
||||
|
||||
test('should return story with composed args and parameters', () => {
|
||||
const Story = () => {};
|
||||
Story.args = { primary: true };
|
||||
Story.parameters = {
|
||||
parameters: {
|
||||
secondAddon: true,
|
||||
},
|
||||
};
|
||||
|
||||
const composedStory = composeStory(Story, meta);
|
||||
expect(composedStory.args).toEqual({ ...Story.args, ...meta.args });
|
||||
expect(composedStory.parameters).toEqual(
|
||||
expect.objectContaining({ ...Story.parameters, ...meta.parameters })
|
||||
);
|
||||
});
|
||||
|
||||
test('should throw an error if Story is undefined', () => {
|
||||
expect(() => {
|
||||
composeStory(undefined, meta);
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('composeStories', () => {
|
||||
test('should call composeStoryFn with stories', () => {
|
||||
const composeConfigFn = jest.fn((v) => v);
|
||||
const module = {
|
||||
default: {
|
||||
title: 'Button',
|
||||
},
|
||||
StoryOne: () => {},
|
||||
StoryTwo: () => {},
|
||||
};
|
||||
const globalConfig = {};
|
||||
composeStories(module, globalConfig, composeConfigFn);
|
||||
expect(composeConfigFn).toHaveBeenCalledWith(
|
||||
module.StoryOne,
|
||||
module.default,
|
||||
globalConfig,
|
||||
'StoryOne'
|
||||
);
|
||||
expect(composeConfigFn).toHaveBeenCalledWith(
|
||||
module.StoryTwo,
|
||||
module.default,
|
||||
globalConfig,
|
||||
'StoryTwo'
|
||||
);
|
||||
});
|
||||
|
||||
test('should not call composeStoryFn for non-story exports', () => {
|
||||
const composeConfigFn = jest.fn((v) => v);
|
||||
const module = {
|
||||
default: {
|
||||
title: 'Button',
|
||||
excludeStories: /Data/,
|
||||
},
|
||||
mockData: {},
|
||||
};
|
||||
composeStories(module, {}, composeConfigFn);
|
||||
expect(composeConfigFn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
130
lib/store/src/csf/testing-utils/index.ts
Normal file
130
lib/store/src/csf/testing-utils/index.ts
Normal file
@ -0,0 +1,130 @@
|
||||
import {
|
||||
isExportStory,
|
||||
AnyFramework,
|
||||
AnnotatedStoryFn,
|
||||
StoryAnnotations,
|
||||
ComponentAnnotations,
|
||||
ProjectAnnotations,
|
||||
Args,
|
||||
StoryContext,
|
||||
Parameters,
|
||||
} from '@storybook/csf';
|
||||
|
||||
import { composeConfigs } from '../composeConfigs';
|
||||
import { prepareStory } from '../prepareStory';
|
||||
import { normalizeStory } from '../normalizeStory';
|
||||
import { HooksContext } from '../../hooks';
|
||||
import { normalizeComponentAnnotations } from '../normalizeComponentAnnotations';
|
||||
import { getValuesFromArgTypes } from '../getValuesFromArgTypes';
|
||||
import { normalizeProjectAnnotations } from '../normalizeProjectAnnotations';
|
||||
import type { CSFExports, ComposedStoryPlayFn } from './types';
|
||||
|
||||
export * from './types';
|
||||
|
||||
let GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS = {};
|
||||
|
||||
export function setProjectAnnotations<TFramework extends AnyFramework = AnyFramework>(
|
||||
projectAnnotations: ProjectAnnotations<TFramework> | ProjectAnnotations<TFramework>[]
|
||||
) {
|
||||
GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS = Array.isArray(projectAnnotations)
|
||||
? composeConfigs(projectAnnotations)
|
||||
: projectAnnotations;
|
||||
}
|
||||
|
||||
interface ComposeStory<TFramework extends AnyFramework = AnyFramework, TArgs extends Args = Args> {
|
||||
(
|
||||
storyAnnotations: AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>,
|
||||
componentAnnotations: ComponentAnnotations<TFramework, TArgs>,
|
||||
projectAnnotations: ProjectAnnotations<TFramework>,
|
||||
exportsName?: string
|
||||
): {
|
||||
(extraArgs: Partial<TArgs>): TFramework['storyResult'];
|
||||
storyName: string;
|
||||
args: Args;
|
||||
play: ComposedStoryPlayFn;
|
||||
parameters: Parameters;
|
||||
};
|
||||
}
|
||||
|
||||
export function composeStory<
|
||||
TFramework extends AnyFramework = AnyFramework,
|
||||
TArgs extends Args = Args
|
||||
>(
|
||||
storyAnnotations: AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>,
|
||||
componentAnnotations: ComponentAnnotations<TFramework, TArgs>,
|
||||
projectAnnotations: ProjectAnnotations<TFramework> = GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS,
|
||||
defaultConfig: ProjectAnnotations<TFramework> = {},
|
||||
exportsName?: string
|
||||
) {
|
||||
if (storyAnnotations === undefined) {
|
||||
throw new Error('Expected a story but received undefined.');
|
||||
}
|
||||
|
||||
// @TODO: Support auto title
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
componentAnnotations.title = componentAnnotations.title ?? 'ComposedStory';
|
||||
const normalizedComponentAnnotations = normalizeComponentAnnotations(componentAnnotations);
|
||||
|
||||
const storyName =
|
||||
exportsName ||
|
||||
storyAnnotations.storyName ||
|
||||
storyAnnotations.story?.name ||
|
||||
storyAnnotations.name;
|
||||
|
||||
const normalizedStory = normalizeStory(
|
||||
storyName,
|
||||
storyAnnotations,
|
||||
normalizedComponentAnnotations
|
||||
);
|
||||
|
||||
const normalizedProjectAnnotations = normalizeProjectAnnotations({
|
||||
...projectAnnotations,
|
||||
...defaultConfig,
|
||||
});
|
||||
|
||||
const story = prepareStory<TFramework>(
|
||||
normalizedStory,
|
||||
normalizedComponentAnnotations,
|
||||
normalizedProjectAnnotations
|
||||
);
|
||||
|
||||
const defaultGlobals = getValuesFromArgTypes(projectAnnotations.globalTypes);
|
||||
|
||||
const composedStory = (extraArgs: Partial<TArgs>) => {
|
||||
const context: Partial<StoryContext> = {
|
||||
...story,
|
||||
hooks: new HooksContext(),
|
||||
globals: defaultGlobals,
|
||||
args: { ...story.initialArgs, ...extraArgs },
|
||||
};
|
||||
|
||||
return story.unboundStoryFn(context as StoryContext);
|
||||
};
|
||||
|
||||
composedStory.storyName = storyName;
|
||||
composedStory.args = story.initialArgs;
|
||||
composedStory.play = story.playFunction as ComposedStoryPlayFn;
|
||||
composedStory.parameters = story.parameters;
|
||||
|
||||
return composedStory;
|
||||
}
|
||||
|
||||
export function composeStories<TModule extends CSFExports>(
|
||||
storiesImport: TModule,
|
||||
globalConfig: ProjectAnnotations<AnyFramework>,
|
||||
composeStoryFn: ComposeStory
|
||||
) {
|
||||
const { default: meta, __esModule, __namedExportsOrder, ...stories } = storiesImport;
|
||||
const composedStories = Object.entries(stories).reduce((storiesMap, [exportsName, story]) => {
|
||||
if (!isExportStory(exportsName, meta)) {
|
||||
return storiesMap;
|
||||
}
|
||||
|
||||
const result = Object.assign(storiesMap, {
|
||||
[exportsName]: composeStoryFn(story, meta, globalConfig, exportsName),
|
||||
});
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
return composedStories;
|
||||
}
|
39
lib/store/src/csf/testing-utils/types.ts
Normal file
39
lib/store/src/csf/testing-utils/types.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import type {
|
||||
AnyFramework,
|
||||
AnnotatedStoryFn,
|
||||
StoryAnnotations,
|
||||
ComponentAnnotations,
|
||||
Args,
|
||||
StoryContext,
|
||||
} from '@storybook/csf';
|
||||
|
||||
export type CSFExports<TFramework extends AnyFramework = AnyFramework> = {
|
||||
default: ComponentAnnotations<TFramework, Args>;
|
||||
__esModule?: boolean;
|
||||
__namedExportsOrder?: string[];
|
||||
};
|
||||
|
||||
export type ComposedStoryPlayContext = Partial<StoryContext> & Pick<StoryContext, 'canvasElement'>;
|
||||
|
||||
export type ComposedStoryPlayFn = (context: ComposedStoryPlayContext) => Promise<void> | void;
|
||||
|
||||
export type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> =
|
||||
AnnotatedStoryFn<TFramework, TArgs> & { play: ComposedStoryPlayFn };
|
||||
|
||||
export type ComposedStory<TFramework extends AnyFramework = AnyFramework, TArgs = Args> =
|
||||
| StoryFn<TFramework, TArgs>
|
||||
| StoryAnnotations<TFramework, TArgs>;
|
||||
|
||||
/**
|
||||
* T represents the whole ES module of a stories file. K of T means named exports (basically the Story type)
|
||||
* 1. pick the keys K of T that have properties that are Story<AnyProps>
|
||||
* 2. infer the actual prop type for each Story
|
||||
* 3. reconstruct Story with Partial. Story<Props> -> Story<Partial<Props>>
|
||||
*/
|
||||
export type StoriesWithPartialProps<TFramework extends AnyFramework, TModule> = {
|
||||
// @TODO once we can use Typescript 4.0 do this to exclude nonStory exports:
|
||||
// replace [K in keyof TModule] with [K in keyof TModule as TModule[K] extends ComposedStory<any> ? K : never]
|
||||
[K in keyof TModule]: TModule[K] extends ComposedStory<infer _, infer TProps>
|
||||
? AnnotatedStoryFn<TFramework, Partial<TProps>>
|
||||
: unknown;
|
||||
};
|
@ -29,6 +29,11 @@ export type ModuleExports = Record<string, any>;
|
||||
type PromiseLike<T> = Promise<T> | SynchronousPromise<T>;
|
||||
export type ModuleImportFn = (path: Path) => PromiseLike<ModuleExports>;
|
||||
|
||||
export type WebProjectAnnotations<TFramework extends AnyFramework> =
|
||||
ProjectAnnotations<TFramework> & {
|
||||
renderToDOM?: (context: RenderContext<TFramework>, element: Element) => Promise<void> | void;
|
||||
};
|
||||
|
||||
export type NormalizedProjectAnnotations<TFramework extends AnyFramework = AnyFramework> =
|
||||
ProjectAnnotations<TFramework> & {
|
||||
argTypes?: StrictArgTypes;
|
||||
|
97
yarn.lock
97
yarn.lock
@ -7217,7 +7217,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@storybook/client-logger@6.5.0-alpha.52, @storybook/client-logger@workspace:*, @storybook/client-logger@workspace:lib/client-logger":
|
||||
"@storybook/client-logger@6.5.0-alpha.52, @storybook/client-logger@^6.4.0 || >=6.5.0-0, @storybook/client-logger@workspace:*, @storybook/client-logger@workspace:lib/client-logger":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/client-logger@workspace:lib/client-logger"
|
||||
dependencies:
|
||||
@ -7236,6 +7236,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/client-logger@npm:6.5.0-alpha.51":
|
||||
version: 6.5.0-alpha.51
|
||||
resolution: "@storybook/client-logger@npm:6.5.0-alpha.51"
|
||||
dependencies:
|
||||
core-js: ^3.8.2
|
||||
global: ^4.4.0
|
||||
checksum: 11b30fde07fb2953573efc212633e870091c90b925af32ec4d0fe76551f13ab2808bed606daebecf3db242baa0a4dca5e18b66cf7efe854dcc3e79e57d69cc29
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/codemod@6.5.0-alpha.52, @storybook/codemod@workspace:*, @storybook/codemod@workspace:lib/codemod":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/codemod@workspace:lib/codemod"
|
||||
@ -7297,6 +7307,22 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@storybook/components@npm:6.5.0-alpha.51":
|
||||
version: 6.5.0-alpha.51
|
||||
resolution: "@storybook/components@npm:6.5.0-alpha.51"
|
||||
dependencies:
|
||||
"@storybook/client-logger": 6.5.0-alpha.51
|
||||
"@storybook/csf": 0.0.2--canary.507502b.0
|
||||
"@storybook/theming": 6.5.0-alpha.51
|
||||
core-js: ^3.8.2
|
||||
regenerator-runtime: ^0.13.7
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17.0.0
|
||||
react-dom: ^16.8.0 || ^17.0.0
|
||||
checksum: af9b1a00f49e9615ff66161b7f6076c253f998a951bf064a870360fd1187bbd96643331ddf43e608bb26db66ef6f964d7886d8bed6a664842909eb3748e46c26
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/core-client@6.5.0-alpha.52, @storybook/core-client@workspace:lib/core-client":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/core-client@workspace:lib/core-client"
|
||||
@ -7680,6 +7706,7 @@ __metadata:
|
||||
"@storybook/react": 6.5.0-alpha.52
|
||||
"@storybook/theming": 6.5.0-alpha.52
|
||||
"@testing-library/dom": ^7.31.2
|
||||
"@testing-library/react": 12.1.2
|
||||
"@testing-library/user-event": ^13.1.9
|
||||
"@types/babel__preset-env": ^7
|
||||
"@types/react": ^16.14.23
|
||||
@ -7734,7 +7761,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@storybook/instrumenter@6.5.0-alpha.52, @storybook/instrumenter@workspace:*, @storybook/instrumenter@workspace:lib/instrumenter":
|
||||
"@storybook/instrumenter@6.5.0-alpha.52, @storybook/instrumenter@^6.4.0 || >=6.5.0-0, @storybook/instrumenter@workspace:*, @storybook/instrumenter@workspace:lib/instrumenter":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/instrumenter@workspace:lib/instrumenter"
|
||||
dependencies:
|
||||
@ -8574,6 +8601,19 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/testing-library@npm:^0.0.9":
|
||||
version: 0.0.9
|
||||
resolution: "@storybook/testing-library@npm:0.0.9"
|
||||
dependencies:
|
||||
"@storybook/client-logger": ^6.4.0 || >=6.5.0-0
|
||||
"@storybook/instrumenter": ^6.4.0 || >=6.5.0-0
|
||||
"@testing-library/dom": ^8.3.0
|
||||
"@testing-library/user-event": ^13.2.1
|
||||
ts-dedent: ^2.2.0
|
||||
checksum: 4a750756a91fd06de58d0d4cf9d7e289ad3e757af6417c97f8d077007a2222a2c31c5f7444eb0d034b1cf11363a1e653718962788c23dca67f33d8691ee63a3b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/theming@6.5.0-alpha.52, @storybook/theming@workspace:*, @storybook/theming@workspace:lib/theming":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/theming@workspace:lib/theming"
|
||||
@ -8621,6 +8661,20 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/theming@npm:6.5.0-alpha.51":
|
||||
version: 6.5.0-alpha.51
|
||||
resolution: "@storybook/theming@npm:6.5.0-alpha.51"
|
||||
dependencies:
|
||||
"@storybook/client-logger": 6.5.0-alpha.51
|
||||
core-js: ^3.8.2
|
||||
regenerator-runtime: ^0.13.7
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17.0.0
|
||||
react-dom: ^16.8.0 || ^17.0.0
|
||||
checksum: 4d50a203c26a12a92b4ce89edfde7a59663c4231dd113687e787fc9e3b72861c215c1134ad844b944d47a5f8ee130425be0968649e21e261afe85277363008a4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@storybook/ui@6.5.0-alpha.52, @storybook/ui@workspace:*, @storybook/ui@workspace:lib/ui":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@storybook/ui@workspace:lib/ui"
|
||||
@ -9089,6 +9143,22 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@testing-library/dom@npm:^8.0.0":
|
||||
version: 8.11.2
|
||||
resolution: "@testing-library/dom@npm:8.11.2"
|
||||
dependencies:
|
||||
"@babel/code-frame": ^7.10.4
|
||||
"@babel/runtime": ^7.12.5
|
||||
"@types/aria-query": ^4.2.0
|
||||
aria-query: ^5.0.0
|
||||
chalk: ^4.1.0
|
||||
dom-accessibility-api: ^0.5.9
|
||||
lz-string: ^1.4.4
|
||||
pretty-format: ^27.0.2
|
||||
checksum: debdabe430b04d548275ad893f97346d437ac2851987793f9da82c41d65bf2dc69c6fa26b8d48e259a203659beb70e831c3542cc8a967333d1377fc536dda0a8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@testing-library/dom@npm:^8.3.0":
|
||||
version: 8.11.3
|
||||
resolution: "@testing-library/dom@npm:8.11.3"
|
||||
@ -9122,6 +9192,19 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@testing-library/react@npm:12.1.2":
|
||||
version: 12.1.2
|
||||
resolution: "@testing-library/react@npm:12.1.2"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.12.5
|
||||
"@testing-library/dom": ^8.0.0
|
||||
peerDependencies:
|
||||
react: "*"
|
||||
react-dom: "*"
|
||||
checksum: c8579252f5f0a23df368253108bbe5b4f26abb9ed5f514746ba6b2ce1a6d09592900526ef6284466af959b50fbb7afa1f37eb2ff629fc91abe70dade3da6cc9a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@testing-library/react@npm:^11.2.2":
|
||||
version: 11.2.7
|
||||
resolution: "@testing-library/react@npm:11.2.7"
|
||||
@ -10077,7 +10160,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/react-dom@npm:^16.9.14":
|
||||
"@types/react-dom@npm:16.9.14, @types/react-dom@npm:^16.9.14":
|
||||
version: 16.9.14
|
||||
resolution: "@types/react-dom@npm:16.9.14"
|
||||
dependencies:
|
||||
@ -17745,12 +17828,16 @@ __metadata:
|
||||
"@storybook/addon-ie11": 0.0.7--canary.5e87b64.0
|
||||
"@storybook/addons": 6.5.0-alpha.52
|
||||
"@storybook/builder-webpack4": 6.5.0-alpha.52
|
||||
"@storybook/components": 6.5.0-alpha.51
|
||||
"@storybook/preset-create-react-app": ^3.1.6
|
||||
"@storybook/react": 6.5.0-alpha.52
|
||||
"@storybook/testing-library": ^0.0.9
|
||||
"@storybook/theming": 6.5.0-alpha.51
|
||||
"@types/jest": ^26.0.16
|
||||
"@types/node": ^14.14.20 || ^16.0.0
|
||||
"@types/react": ^16.14.23
|
||||
"@types/react-dom": ^16.9.14
|
||||
"@types/react-dom": 16.9.14
|
||||
formik: 2.2.9
|
||||
global: ^4.4.0
|
||||
react: 16.14.0
|
||||
react-dom: 16.14.0
|
||||
@ -23098,7 +23185,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"formik@npm:^2.2.9":
|
||||
"formik@npm:2.2.9, formik@npm:^2.2.9":
|
||||
version: 2.2.9
|
||||
resolution: "formik@npm:2.2.9"
|
||||
dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user