-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Introduce setProjectAnnotations API to more renderers and frameworks #28907
Changes from all commits
0b6f53d
18df216
0809eb5
3229c13
a38643e
1738902
7ff1345
67afdd1
8399ee1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './types'; | ||
export * from './portable-stories'; |
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>[] | ||
Comment on lines
+38
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using a more specific type than |
||
): 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, | ||
]); |
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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Update import statement to use '@storybook/html' instead of '@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>; | ||
} |
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>[] | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using a more specific type than |
||
): NormalizedProjectAnnotations<PreactRenderer> { | ||
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<PreactRenderer>; | ||
} |
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>[] | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using a more specific type than |
||
): NormalizedProjectAnnotations<WebComponentsRenderer> { | ||
setDefaultProjectAnnotations(webComponentsAnnotations); | ||
return originalSetProjectAnnotations( | ||
projectAnnotations | ||
) as NormalizedProjectAnnotations<WebComponentsRenderer>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a more specific type than
any
for better type safety