Loading...
Loading...
Compare original and translation side by side
const meta = {
title: 'Components/Button',
component: Button,
tags: ['autodocs'], // Enable auto-documentation
parameters: {
docs: {
description: {
component: 'A versatile button component with multiple variants and sizes.',
},
},
},
} satisfies Meta<typeof Button>;const meta = {
title: 'Components/Button',
component: Button,
tags: ['autodocs'], // Enable auto-documentation
parameters: {
docs: {
description: {
component: 'A versatile button component with multiple variants and sizes.',
},
},
},
} satisfies Meta<typeof Button>;import { Meta, Canvas, Story, Controls } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';
<Meta of={ButtonStories} />import { Meta, Canvas, Story, Controls } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';
<Meta of={ButtonStories} />interface ButtonProps {
/**
* The button label text
*/
label: string;
/**
* Is this the principal call to action?
* @default false
*/
primary?: boolean;
/**
* Button size variant
* @default 'medium'
*/
size?: 'small' | 'medium' | 'large';
}interface ButtonProps {
/**
* The button label text
*/
label: string;
/**
* Is this the principal call to action?
* @default false
*/
primary?: boolean;
/**
* Button size variant
* @default 'medium'
*/
size?: 'small' | 'medium' | 'large';
}autodocsconst meta = {
component: Button,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Button component with primary and secondary variants.',
},
},
},
} satisfies Meta<typeof Button>;autodocsconst meta = {
component: Button,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Button component with primary and secondary variants.',
},
},
},
} satisfies Meta<typeof Button>;const meta = {
component: Tooltip,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: `
Tooltip displays helpful information when users hover over an element.
Supports multiple placements and can be triggered by hover, click, or focus.const meta = {
component: Tooltip,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: `
Tooltip displays helpful information when users hover over an element.
Supports multiple placements and can be triggered by hover, click, or focus.undefinedundefinedexport const WithIcon: Story = {
args: {
label: 'Download',
icon: 'download',
},
parameters: {
docs: {
description: {
story: 'Buttons can include icons to enhance visual communication.',
},
},
},
};
export const Loading: Story = {
args: {
loading: true,
label: 'Processing...',
},
parameters: {
docs: {
description: {
story: 'Loading state disables interaction and shows a spinner.',
},
},
},
};export const WithIcon: Story = {
args: {
label: 'Download',
icon: 'download',
},
parameters: {
docs: {
description: {
story: 'Buttons can include icons to enhance visual communication.',
},
},
},
};
export const Loading: Story = {
args: {
loading: true,
label: 'Processing...',
},
parameters: {
docs: {
description: {
story: 'Loading state disables interaction and shows a spinner.',
},
},
},
};interface CardProps {
/**
* Card title displayed at the top
*/
title: string;
/**
* Optional subtitle below the title
*/
subtitle?: string;
/**
* Card variant affecting visual style
* @default 'default'
*/
variant?: 'default' | 'outlined' | 'elevated';
/**
* Card content
*/
children: React.ReactNode;
/**
* Called when card is clicked
* @param event - The click event
*/
onClick?: (event: React.MouseEvent) => void;
/**
* Elevation level (shadow depth)
* @minimum 0
* @maximum 5
* @default 1
*/
elevation?: number;
}interface CardProps {
/**
* Card title displayed at the top
*/
title: string;
/**
* Optional subtitle below the title
*/
subtitle?: string;
/**
* Card variant affecting visual style
* @default 'default'
*/
variant?: 'default' | 'outlined' | 'elevated';
/**
* Card content
*/
children: React.ReactNode;
/**
* Called when card is clicked
* @param event - The click event
*/
onClick?: (event: React.MouseEvent) => void;
/**
* Elevation level (shadow depth)
* @minimum 0
* @maximum 5
* @default 1
*/
elevation?: number;
}import { Meta, Canvas, Story } from '@storybook/blocks';
import * as FormStories from './Form.stories';
<Meta of={FormStories} />import { Meta, Canvas, Story } from '@storybook/blocks';
import * as FormStories from './Form.stories';
<Meta of={FormStories} />import { Form } from './Form';
function MyForm() {
return (
<Form
onSubmit={(data) => console.log(data)}
validationSchema={schema}
>
<Input name="email" label="Email" />
<Button type="submit">Submit</Button>
</Form>
);
}undefinedimport { Form } from './Form';
function MyForm() {
return (
<Form
onSubmit={(data) => console.log(data)}
validationSchema={schema}
>
<Input name="email" label="Email" />
<Button type="submit">Submit</Button>
</Form>
);
}undefinedimport { Meta, Canvas, Controls } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';
<Meta of={ButtonStories} />import { Meta, Canvas, Controls } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';
<Meta of={ButtonStories} />undefinedundefinedconst meta = {
component: DataGrid,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Advanced data grid with sorting, filtering, and pagination.',
},
},
},
argTypes: {
data: {
description: 'Array of data objects to display',
table: {
type: { summary: 'Array<Record<string, any>>' },
},
},
columns: {
description: 'Column configuration',
table: {
type: { summary: 'ColumnDef[]' },
},
},
onRowClick: {
description: 'Callback fired when a row is clicked',
table: {
type: { summary: '(row: any, index: number) => void' },
},
},
},
} satisfies Meta<typeof DataGrid>;const meta = {
component: DataGrid,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Advanced data grid with sorting, filtering, and pagination.',
},
},
},
argTypes: {
data: {
description: 'Array of data objects to display',
table: {
type: { summary: 'Array<Record<string, any>>' },
},
},
columns: {
description: 'Column configuration',
table: {
type: { summary: 'ColumnDef[]' },
},
},
onRowClick: {
description: 'Callback fired when a row is clicked',
table: {
type: { summary: '(row: any, index: number) => void' },
},
},
},
} satisfies Meta<typeof DataGrid>;import { Meta } from '@storybook/blocks';
<Meta title="Guides/Migration/v2 to v3" />import { Meta } from '@storybook/blocks';
<Meta title="Guides/Migration/v2 to v3" /><Button type="primary">Click me</Button><Button variant="primary">Click me</Button>typevariant<Button type="primary">Click me</Button><Button variant="primary">Click me</Button>typevariant<Input error="Invalid email" /><Input error={{ message: "Invalid email" }} /><Input error="Invalid email" /><Input error={{ message: "Invalid email" }} /><Button variant="primary" icon="check">
Save
</Button>undefined<Button variant="primary" icon="check">
Save
</Button>undefinedimport { Meta, ColorPalette, ColorItem, Typeset } from '@storybook/blocks';
<Meta title="Design System/Colors" />import { Meta, ColorPalette, ColorItem, Typeset } from '@storybook/blocks';
<Meta title="Design System/Colors" />undefinedundefinedimport { Meta, Story } from '@storybook/blocks';
import { Button } from './Button';
<Meta title="Components/Button/Examples" component={Button} />import { Meta, Story } from '@storybook/blocks';
import { Button } from './Button';
<Meta title="Components/Button/Examples" component={Button} />import { Source } from '@storybook/blocks';
<Meta title="Guides/Setup" />import { Source } from '@storybook/blocks';
<Meta title="Guides/Setup" />undefinedundefined// Bad
const meta = {
component: Button,
tags: ['autodocs'],
} satisfies Meta<typeof Button>;// Good
const meta = {
component: Button,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Primary UI component for user actions.',
},
},
},
} satisfies Meta<typeof Button>;// 错误示例
const meta = {
component: Button,
tags: ['autodocs'],
} satisfies Meta<typeof Button>;// 正确示例
const meta = {
component: Button,
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Primary UI component for user actions.',
},
},
},
} satisfies Meta<typeof Button>;// Bad
interface ButtonProps {
/** The label */
label: string;
/** The size */
size?: string;
}// Good
interface ButtonProps {
/** Text displayed on the button */
label: string;
/**
* Visual size of the button
* @default 'medium'
*/
size?: 'small' | 'medium' | 'large';
}// 错误示例
interface ButtonProps {
/** The label */
label: string;
/** The size */
size?: string;
}// 正确示例
interface ButtonProps {
/** Text displayed on the button */
label: string;
/**
* Visual size of the button
* @default 'medium'
*/
size?: 'small' | 'medium' | 'large';
}// Bad
export const Disabled: Story = {
args: { disabled: true },
};// Good
export const Disabled: Story = {
args: { disabled: true },
parameters: {
docs: {
description: {
story: 'Disabled state prevents user interaction and dims the button visually.',
},
},
},
};// 错误示例
export const Disabled: Story = {
args: { disabled: true },
};// 正确示例
export const Disabled: Story = {
args: { disabled: true },
parameters: {
docs: {
description: {
story: 'Disabled state prevents user interaction and dims the button visually.',
},
},
},
};