Skip to content

Commit

Permalink
Merge branch 'chore/docs-theming' into feat/storybook-v8
Browse files Browse the repository at this point in the history
  • Loading branch information
naporin0624 committed Apr 17, 2024
2 parents 4cb3abb + a8ac1cd commit 1461048
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .storybook/docs-container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { ComponentPropsWithoutRef, FC } from 'react'
import { DocsContainer as BaseContainer } from '@storybook/addon-docs'
import { useDarkMode } from 'storybook-dark-mode'
import { themes } from '@storybook/theming'

export const DocsContainer: FC<
ComponentPropsWithoutRef<typeof BaseContainer>
> = ({ children, ...rest }) => {
const dark = useDarkMode()

return (
<BaseContainer {...rest} theme={dark ? themes.dark : themes.light}>
{children}
</BaseContainer>
)
}
7 changes: 7 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import themeDecorator from './theme-decorator'
import { DocsContainer } from './docs-container'

import './global.css'

/** @type */
export const parameters = {
actions: { argTypesRegex: '^on[A-Z0-9].*' },
controls: {
Expand All @@ -9,6 +12,10 @@ export const parameters = {
date: /Date$/,
},
},
viewMode: 'docs',
docs: {
container: DocsContainer,
},
}

export const decorators = [themeDecorator]

0 comments on commit 1461048

Please sign in to comment.