0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:40:03 +01:00
posthog/.storybook/decorators/withTheme.tsx

14 lines
368 B
TypeScript
Raw Permalink Normal View History

import type { Decorator } from '@storybook/react'
/** Global story decorator that is used by the theming control to
* switch between themes.
*/
export const withTheme: Decorator = (Story, context) => {
const theme = context.globals.theme
// set the theme
document.body.setAttribute('theme', theme === 'dark' ? 'dark' : 'light')
return <Story />
}