mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
HTML: Introduce setProjectAnnotations API
This commit is contained in:
parent
18df216270
commit
0809eb5e2a
@ -2,6 +2,7 @@
|
||||
import './globals';
|
||||
|
||||
export * from './public-types';
|
||||
export * from './portable-stories';
|
||||
|
||||
// optimization: stop HMR propagation in webpack
|
||||
|
||||
|
41
code/renderers/html/src/portable-stories.ts
Normal file
41
code/renderers/html/src/portable-stories.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {
|
||||
setProjectAnnotations as originalSetProjectAnnotations,
|
||||
setDefaultProjectAnnotations,
|
||||
} from 'storybook/internal/preview-api';
|
||||
import type {
|
||||
NamedOrDefaultProjectAnnotations,
|
||||
NormalizedProjectAnnotations,
|
||||
} from 'storybook/internal/types';
|
||||
|
||||
import * as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS from './entry-preview';
|
||||
import type { HtmlRenderer } from './types';
|
||||
|
||||
/**
|
||||
* Function that sets the globalConfig of your storybook. The global config is the preview module of
|
||||
* your .storybook folder.
|
||||
*
|
||||
* It should be run a single time, so that your global config (e.g. decorators) is applied to your
|
||||
* stories when using `composeStories` or `composeStory`.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```jsx
|
||||
* // setup-file.js
|
||||
* import { setProjectAnnotations } from '@storybook/preact';
|
||||
* import projectAnnotations from './.storybook/preview';
|
||||
*
|
||||
* setProjectAnnotations(projectAnnotations);
|
||||
* ```
|
||||
*
|
||||
* @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')
|
||||
*/
|
||||
export function setProjectAnnotations(
|
||||
projectAnnotations:
|
||||
| NamedOrDefaultProjectAnnotations<any>
|
||||
| NamedOrDefaultProjectAnnotations<any>[]
|
||||
): NormalizedProjectAnnotations<HtmlRenderer> {
|
||||
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS);
|
||||
return originalSetProjectAnnotations(
|
||||
projectAnnotations
|
||||
) as NormalizedProjectAnnotations<HtmlRenderer>;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user