mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
59 lines
1.2 KiB
Plaintext
59 lines
1.2 KiB
Plaintext
```tsx
|
|
// MyComponent.stories.ts|tsx
|
|
|
|
// Replace your-framework with the name of your framework
|
|
import type { Meta } from '@storybook/your-framework';
|
|
|
|
import { ColorItem, ColorPalette } from '@storybook/blocks';
|
|
|
|
import { MyComponent } from './MyComponent';
|
|
|
|
const meta = {
|
|
component: MyComponent,
|
|
} satisfies Meta<typeof MyComponent>;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
const theme = {
|
|
colors: {
|
|
primaryDark: {
|
|
value: '#1C1C1C',
|
|
},
|
|
primaryRegular: {
|
|
value: '#363636',
|
|
},
|
|
primaryLight1: {
|
|
value: '#4D4D4D',
|
|
},
|
|
primaryLight2: {
|
|
value: '#878787',
|
|
},
|
|
primaryLight3: {
|
|
value: '#D1D1D1',
|
|
},
|
|
primaryLight4: {
|
|
value: '#EDEDED',
|
|
},
|
|
},
|
|
};
|
|
|
|
// ❌ Don't use the Doc Blocks inside your stories. It will break Storybook with a cryptic error.
|
|
export const Colors: Story = {
|
|
render: () => (
|
|
<ColorPalette>
|
|
{Object.entries(theme.colors).map(([key, { value }]) => (
|
|
<ColorItem
|
|
colors={{
|
|
[key]: value,
|
|
}}
|
|
key={key}
|
|
subtitle={`theme.colors.${key}`}
|
|
title={key}
|
|
/>
|
|
))}
|
|
</ColorPalette>
|
|
),
|
|
};
|
|
```
|