mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Try it out in Button.stories.tsx
This commit is contained in:
parent
9415e4736b
commit
9fc6fbe57d
@ -17,6 +17,7 @@ import {
|
||||
import { DocsContext } from '@storybook/blocks';
|
||||
import { global } from '@storybook/global';
|
||||
import type { Decorator, Loader, ReactRenderer } from '@storybook/react';
|
||||
import { defineConfig } from '@storybook/react/preview';
|
||||
|
||||
import { DocsPageWrapper } from '../lib/blocks/src/components';
|
||||
import { isChromatic } from './isChromatic';
|
||||
@ -361,3 +362,9 @@ export const parameters = {
|
||||
};
|
||||
|
||||
export const tags = ['test', 'vitest', '!a11ytest'];
|
||||
|
||||
export const config = defineConfig({
|
||||
parameters,
|
||||
tags,
|
||||
decorators,
|
||||
});
|
||||
|
@ -4,13 +4,14 @@ import React from 'react';
|
||||
import { FaceHappyIcon } from '@storybook/icons';
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { config } from '../../../../../.storybook/preview';
|
||||
import { Button } from './Button';
|
||||
|
||||
const meta = {
|
||||
const meta = config.meta({
|
||||
title: 'Button',
|
||||
component: Button,
|
||||
args: { children: 'Button' },
|
||||
} satisfies Meta<typeof Button>;
|
||||
});
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
@ -25,6 +25,11 @@
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./preview": {
|
||||
"types": "./dist/preview.d.ts",
|
||||
"import": "./dist/preview.mjs",
|
||||
"require": "./dist/preview.js"
|
||||
},
|
||||
"./experimental-playwright": {
|
||||
"types": "./dist/playwright.d.ts",
|
||||
"import": "./dist/playwright.mjs",
|
||||
@ -44,6 +49,9 @@
|
||||
"*": [
|
||||
"dist/index.d.ts"
|
||||
],
|
||||
"preview": [
|
||||
"dist/preview.d.ts"
|
||||
],
|
||||
"experimental-playwright": [
|
||||
"dist/playwright.d.ts"
|
||||
]
|
||||
@ -116,6 +124,7 @@
|
||||
"entries": [
|
||||
"./src/index.ts",
|
||||
"./src/preset.ts",
|
||||
"./src/preview.tsx",
|
||||
"./src/entry-preview.tsx",
|
||||
"./src/entry-preview-docs.ts",
|
||||
"./src/entry-preview-rsc.tsx",
|
||||
|
@ -1,16 +1,14 @@
|
||||
import type { ComponentProps, ComponentType } from 'react';
|
||||
import type { ComponentType } from 'react';
|
||||
|
||||
import { composeConfigs } from 'storybook/internal/preview-api';
|
||||
import { prepareStory } from 'storybook/internal/preview-api';
|
||||
import type { NormalizedProjectAnnotations } from 'storybook/internal/types';
|
||||
|
||||
import type {
|
||||
Args,
|
||||
ComponentAnnotations,
|
||||
NormalizedProjectAnnotations,
|
||||
ProjectAnnotations,
|
||||
Renderer,
|
||||
StoryAnnotations,
|
||||
} from '@storybook/csf';
|
||||
} from 'storybook/internal/types';
|
||||
|
||||
import type { ReactRenderer } from './types';
|
||||
|
||||
@ -18,8 +16,8 @@ export function defineConfig(config: PreviewConfigData<ReactRenderer>) {
|
||||
return new PreviewConfig(config);
|
||||
}
|
||||
|
||||
interface PreviewConfigData<TRenderer extends Renderer> {
|
||||
addons: ProjectAnnotations<TRenderer>[];
|
||||
interface PreviewConfigData<TRenderer extends Renderer> extends ProjectAnnotations<TRenderer> {
|
||||
addons?: ProjectAnnotations<TRenderer>[];
|
||||
}
|
||||
|
||||
class PreviewConfig<TRenderer extends Renderer> {
|
||||
@ -27,7 +25,7 @@ class PreviewConfig<TRenderer extends Renderer> {
|
||||
|
||||
constructor(data: PreviewConfigData<TRenderer>) {
|
||||
const { addons, ...rest } = data;
|
||||
this.annotations = composeConfigs([rest, ...addons]);
|
||||
this.annotations = composeConfigs([rest, ...(addons ?? [])]);
|
||||
}
|
||||
|
||||
readonly meta = <TComponent extends ComponentType<any>, TMetaArgs extends Args>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user