-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28907 from storybookjs/yann/introduce-project-ann…
…otations-to-other-packages Core: Introduce setProjectAnnotations API to more renderers and frameworks
- Loading branch information
Showing
17 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
setProjectAnnotations as originalSetProjectAnnotations, | ||
setDefaultProjectAnnotations, | ||
} from 'storybook/internal/preview-api'; | ||
import { | ||
NamedOrDefaultProjectAnnotations, | ||
NormalizedProjectAnnotations, | ||
} from 'storybook/internal/types'; | ||
|
||
import * as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS from './render'; | ||
import { AngularRenderer } 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/angular'; | ||
* | ||
* 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<AngularRenderer> { | ||
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<AngularRenderer>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './types'; | ||
export * from './portable-stories'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
composeConfigs, | ||
setProjectAnnotations as originalSetProjectAnnotations, | ||
setDefaultProjectAnnotations, | ||
} from 'storybook/internal/preview-api'; | ||
import type { | ||
NamedOrDefaultProjectAnnotations, | ||
NormalizedProjectAnnotations, | ||
ProjectAnnotations, | ||
} from 'storybook/internal/types'; | ||
|
||
import type { SvelteRenderer } from '@storybook/svelte'; | ||
import { INTERNAL_DEFAULT_PROJECT_ANNOTATIONS as svelteAnnotations } from '@storybook/svelte'; | ||
|
||
import * as svelteKitAnnotations from './preview'; | ||
|
||
/** | ||
* 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/sveltekit'; | ||
* 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<SvelteRenderer> { | ||
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<SvelteRenderer>; | ||
} | ||
|
||
// This will not be necessary once we have auto preset loading | ||
const INTERNAL_DEFAULT_PROJECT_ANNOTATIONS: ProjectAnnotations<SvelteRenderer> = composeConfigs([ | ||
svelteAnnotations, | ||
svelteKitAnnotations, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { PreactRenderer } 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<PreactRenderer> { | ||
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<PreactRenderer>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
setProjectAnnotations as originalSetProjectAnnotations, | ||
setDefaultProjectAnnotations, | ||
} from 'storybook/internal/preview-api'; | ||
import type { | ||
NamedOrDefaultProjectAnnotations, | ||
NormalizedProjectAnnotations, | ||
} from 'storybook/internal/types'; | ||
|
||
import * as webComponentsAnnotations from './entry-preview'; | ||
import type { WebComponentsRenderer } 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/web-components'; | ||
* 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<WebComponentsRenderer> { | ||
setDefaultProjectAnnotations(webComponentsAnnotations); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<WebComponentsRenderer>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters