0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:15:44 +01:00
posthog/.storybook/decorators/withTheme.tsx
2024-02-23 09:50:50 +00:00

14 lines
368 B
TypeScript

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 />
}