re-use the previewAnnotation files

This commit is contained in:
Norbert de Langen 2024-07-18 13:45:33 +02:00
parent 20efb2af27
commit 1036b0e1ce
4 changed files with 39 additions and 26 deletions

View File

@ -28,17 +28,41 @@ const config: StorybookConfig = {
directory: '../lib/blocks/src',
titlePrefix: 'blocks',
},
{
directory: '../addons/a11y/template/stories',
titlePrefix: 'addons/a11y',
},
{
directory: '../addons/actions/template/stories',
titlePrefix: 'addons/actions',
},
{
directory: '../addons/backgrounds/template/stories',
titlePrefix: 'addons/backgrounds',
},
{
directory: '../addons/controls/src',
titlePrefix: 'addons/controls',
},
{
directory: '../addons/controls/template/stories',
titlePrefix: 'addons/controls',
},
{
directory: '../addons/docs/template/stories',
titlePrefix: 'addons/docs',
},
{
directory: '../addons/links/template/stories',
titlePrefix: 'addons/links',
},
{
directory: '../addons/viewport/template/stories',
titlePrefix: 'addons/viewport',
},
{
directory: '../addons/backgrounds/template/stories',
titlePrefix: 'addons/backgrounds',
directory: '../addons/toolbars/template/stories',
titlePrefix: 'addons/toolbars',
},
{
directory: '../addons/onboarding/src',
@ -48,6 +72,10 @@ const config: StorybookConfig = {
directory: '../addons/interactions/src',
titlePrefix: 'addons/interactions',
},
{
directory: '../addons/interactions/template/stories',
titlePrefix: 'addons/interactions',
},
],
addons: [
'@storybook/addon-links',
@ -58,6 +86,11 @@ const config: StorybookConfig = {
'@storybook/addon-a11y',
'@chromatic-com/storybook',
],
previewAnnotations: [
'./core/template/stories/preview.ts',
'./addons/toolbars/template/stories/preview.ts',
'./renderers/react/template/components/index.js',
],
build: {
test: {
// we have stories for the blocks here, we can't exclude them

View File

@ -15,8 +15,6 @@ import type { PreviewWeb } from 'storybook/internal/preview-api';
import type { ReactRenderer } from '@storybook/react';
import type { Channel } from 'storybook/internal/channels';
import '../renderers/react/template/components';
import { DocsContext } from '@storybook/blocks';
import { DocsPageWrapper } from '../lib/blocks/src/components';
@ -136,7 +134,6 @@ export const loaders = [
}
return { docsContext };
},
async () => ({ projectValue: 2 }),
];
export const decorators = [
@ -262,20 +259,9 @@ export const decorators = [
</>
);
},
(storyFn: PartialStoryFn, context: StoryContext) => {
if (context.parameters.useProjectDecorator)
return storyFn({ args: { ...context.args, text: `project ${context.args.text}` } });
return storyFn();
},
];
export const parameters = {
projectParameter: 'projectParameter',
storyObject: {
a: 'project',
b: 'project',
c: 'project',
},
options: {
storySort: (a, b) =>
a.title === b.title ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true }),
@ -328,11 +314,4 @@ export const globalTypes = {
],
},
},
foo: { defaultValue: 'fooDefaultValue' },
bar: { defaultValue: 'barDefaultValue' },
};
export const initialGlobals = {
foo: 'fooValue',
baz: 'bazValue',
};

View File

@ -1,10 +1,11 @@
import { global as globalThis } from '@storybook/global';
import { userEvent, within } from '@storybook/test';
import { fn, userEvent, within } from '@storybook/test';
export default {
component: globalThis.Components.Button,
args: {
label: 'Button',
onClick: fn(),
},
argTypes: {
onClick: { type: 'function' },

View File

@ -103,7 +103,7 @@ export class Preview<TRenderer extends Renderer> {
// Create a proxy object for `__STORYBOOK_STORY_STORE__` and `__STORYBOOK_PREVIEW__.storyStore`
// That proxies through to the store once ready, and errors beforehand. This means we can set
// `__STORYBOOK_STORY_STORE__ = __STORYBOOK_PREVIEW__.storyStore` without having to wait, and
// simiarly integrators can access the `storyStore` on the preview at any time, although
// similarly integrators can access the `storyStore` on the preview at any time, although
// it is considered deprecated and we will no longer allow access in 9.0
get storyStore() {
return new Proxy(
@ -118,7 +118,7 @@ export class Preview<TRenderer extends Renderer> {
throw new StoryStoreAccessedBeforeInitializationError();
},
}
);
) as StoryStore<TRenderer>;
}
// INITIALIZATION