0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/.storybook/decorators/withFeatureFlags.tsx
2023-10-27 22:47:36 +02:00

29 lines
668 B
TypeScript

import { setFeatureFlags } from '~/mocks/browser'
import type { Decorator } from '@storybook/react'
declare module '@storybook/types' {
interface Parameters {
featureFlags?: string[]
}
}
/** Global story decorator that allows setting feature flags.
*
* ```ts
* export default {
* title: 'My story',
* component: MyComponent,
* parameters: {
* featureFlags: ['hogql'], // add flags here
* },
* } as ComponentMeta<typeof MyComponent>
* ```
*/
export const withFeatureFlags: Decorator = (Story, { parameters }) => {
if (parameters.featureFlags) {
setFeatureFlags(parameters.featureFlags)
}
return <Story />
}