-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storybook] Improve typing, add doc links & remove redundant JSDoc in…
… preview.tsx (#11745) Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
- Loading branch information
Showing
5 changed files
with
48 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- [Storybook] Improve typing, add doc links & remove redundant JSDoc in preview.tsx (#11745) by @Philzen | ||
|
||
Better types for storybook preview config | ||
Better IntelliSense hints for storybook |
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
22 changes: 11 additions & 11 deletions
22
packages/cli/src/commands/setup/ui/templates/chakra.storybook.preview.tsx.template
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,20 +1,20 @@ | ||
import * as React from 'react' | ||
|
||
import { ChakraProvider, extendTheme } from '@chakra-ui/react' | ||
import type { StoryFn } from '@storybook/react' | ||
import type { Preview, StoryFn } from '@storybook/react' | ||
import theme from 'config/chakra.config' | ||
|
||
const extendedTheme = extendTheme(theme) | ||
|
||
/** | ||
* @param { import("@storybook/react").StoryFn} StoryFn | ||
*/ | ||
const withChakra = (StoryFn: StoryFn) => { | ||
return ( | ||
<ChakraProvider theme={extendedTheme}> | ||
<StoryFn /> | ||
</ChakraProvider> | ||
) | ||
/** @see {@link https://storybook.js.org/docs/7/essentials/toolbars-and-globals#create-a-decorator | Create a decorator} */ | ||
const withChakra = (Story: StoryFn) => ( | ||
<ChakraProvider theme={extendedTheme}> | ||
<Story /> | ||
</ChakraProvider> | ||
) | ||
|
||
const preview: Preview = { | ||
decorators: [withChakra] | ||
} | ||
|
||
export const decorators = [withChakra] | ||
export default preview |
22 changes: 10 additions & 12 deletions
22
packages/cli/src/commands/setup/ui/templates/mantine.storybook.preview.tsx.template
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,20 +1,18 @@ | ||
import * as React from 'react' | ||
|
||
import { MantineProvider } from '@mantine/core' | ||
import type { StoryFn } from '@storybook/react' | ||
import type { Preview, StoryFn } from '@storybook/react' | ||
import theme from 'config/mantine.config' | ||
|
||
import '@mantine/core/styles.css' | ||
|
||
/** | ||
* @param { import("@storybook/react").StoryFn} StoryFn | ||
*/ | ||
const withMantine = (StoryFn: StoryFn) => { | ||
return ( | ||
<MantineProvider theme={theme}> | ||
<StoryFn /> | ||
</MantineProvider> | ||
) | ||
} | ||
/** @see {@link https://storybook.js.org/docs/7/essentials/toolbars-and-globals#create-a-decorator | Create a decorator} */ | ||
const withMantine = (Story: StoryFn) => ( | ||
<MantineProvider theme={theme}> | ||
<Story /> | ||
</MantineProvider> | ||
) | ||
|
||
export const decorators = [withMantine] | ||
const preview: Preview = { | ||
decorators: [withMantine] | ||
} |
19 changes: 11 additions & 8 deletions
19
packages/cli/src/lib/templates/storybook.preview.tsx.template
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,18 +1,21 @@ | ||
import * as React from 'react' | ||
|
||
import type { GlobalTypes } from '@storybook/csf' | ||
import type { StoryFn, StoryContext } from '@storybook/react' | ||
import type { Preview, StoryContext, StoryFn } from '@storybook/react' | ||
|
||
/** @type { import("@storybook/csf").GlobalTypes } */ | ||
/** @see {@link https://storybook.js.org/docs/7/essentials/toolbars-and-globals#global-types-and-the-toolbar-annotation | Global types and the toolbar annotation} */ | ||
export const globalTypes: GlobalTypes = {} | ||
|
||
/** | ||
* An example, no-op storybook decorator. Use a function like this to create decorators. | ||
* @param { import("@storybook/react").StoryFn} StoryFn | ||
* @param { import("@storybook/react").StoryContext} context | ||
*/ | ||
const _exampleDecorator = (StoryFn: StoryFn, _context: StoryContext) => { | ||
return <StoryFn /> | ||
* @see {@link https://storybook.js.org/docs/7/essentials/toolbars-and-globals#create-a-decorator | Create a decorator} | ||
*/ | ||
const _exampleDecorator = (StoryFn: StoryFn, _context: StoryContext) => ( | ||
<StoryFn /> | ||
) | ||
|
||
const preview: Preview = { | ||
decorators: [], | ||
} | ||
|
||
export const decorators = [] | ||
export default preview |