feat(component): enhance storybook preview (#943)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { getLightTheme, ThemeProvider } from '../src';
|
||||||
|
|
||||||
export const parameters = {
|
export const parameters = {
|
||||||
actions: { argTypesRegex: '^on[A-Z].*' },
|
actions: { argTypesRegex: '^on[A-Z].*' },
|
||||||
controls: {
|
controls: {
|
||||||
@@ -7,3 +9,15 @@ export const parameters = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const lightTheme = getLightTheme('page');
|
||||||
|
|
||||||
|
export const decorators = [
|
||||||
|
Story => {
|
||||||
|
return (
|
||||||
|
<ThemeProvider theme={lightTheme}>
|
||||||
|
<Story />
|
||||||
|
</ThemeProvider>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
import React, { useMemo } from 'react';
|
/* deepscan-disable USELESS_ARROW_FUNC_BIND */
|
||||||
|
import React from 'react';
|
||||||
import { Meta, Story } from '@storybook/react';
|
import { Meta, Story } from '@storybook/react';
|
||||||
import { Breadcrumbs, getLightTheme, ThemeProvider } from '..';
|
import { Breadcrumbs } from '..';
|
||||||
|
import { Link, Typography } from '@mui/material';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'AFFiNE/Breadcrumbs',
|
title: 'AFFiNE/Breadcrumbs',
|
||||||
component: Breadcrumbs,
|
component: Breadcrumbs,
|
||||||
} as Meta;
|
} as Meta;
|
||||||
|
|
||||||
const Template: Story = args => (
|
const Template: Story = args => <Breadcrumbs {...args} />;
|
||||||
<ThemeProvider theme={useMemo(() => getLightTheme('page'), [])}>
|
|
||||||
<Breadcrumbs {...args} />
|
|
||||||
</ThemeProvider>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Primary = Template.bind({});
|
export const Primary = Template.bind(undefined);
|
||||||
Primary.args = {
|
Primary.args = {
|
||||||
children: [<span>1</span>, <span>2</span>, <span>3</span>],
|
children: [
|
||||||
|
<Link underline="hover" color="inherit" href="/">
|
||||||
|
AFFiNE
|
||||||
|
</Link>,
|
||||||
|
<Link underline="hover" color="inherit" href="/Docs/">
|
||||||
|
Docs
|
||||||
|
</Link>,
|
||||||
|
<Typography color="text.primary">Introduction</Typography>,
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,46 @@
|
|||||||
import React, { useMemo } from 'react';
|
/* deepscan-disable USELESS_ARROW_FUNC_BIND */
|
||||||
|
import React from 'react';
|
||||||
import { Meta, Story } from '@storybook/react';
|
import { Meta, Story } from '@storybook/react';
|
||||||
import { Button, getLightTheme, ThemeProvider } from '..';
|
import { Button } from '..';
|
||||||
|
import { ButtonProps } from '../ui/button/interface';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'AFFiNE/Button',
|
title: 'AFFiNE/Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
} as Meta;
|
argTypes: {
|
||||||
|
hoverBackground: { control: 'color' },
|
||||||
|
hoverColor: { control: 'color' },
|
||||||
|
},
|
||||||
|
} as Meta<ButtonProps>;
|
||||||
|
|
||||||
const Template: Story = args => (
|
const Template: Story<ButtonProps> = args => <Button {...args} />;
|
||||||
<ThemeProvider theme={useMemo(() => getLightTheme('page'), [])}>
|
|
||||||
<Button {...args} />
|
|
||||||
</ThemeProvider>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Primary = Template.bind({});
|
export const Primary = Template.bind(undefined);
|
||||||
Primary.args = {
|
Primary.args = {
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
children: 'This is a button',
|
children: 'This is a primary button',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Default = Template.bind(undefined);
|
||||||
|
Default.args = {
|
||||||
|
type: 'default',
|
||||||
|
children: 'This is a default button',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Light = Template.bind(undefined);
|
||||||
|
Light.args = {
|
||||||
|
type: 'light',
|
||||||
|
children: 'This is a light button',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Warning = Template.bind(undefined);
|
||||||
|
Warning.args = {
|
||||||
|
type: 'warning',
|
||||||
|
children: 'This is a warning button',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Danger = Template.bind(undefined);
|
||||||
|
Danger.args = {
|
||||||
|
type: 'danger',
|
||||||
|
children: 'This is a danger button',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user