0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00
posthog/.storybook/decorators/withTheme.tsx

14 lines
368 B
TypeScript
Raw 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 />
}