0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/.storybook/decorators/withFeatureFlags.tsx

23 lines
568 B
TypeScript
Raw Normal View History

import { useFeatureFlags } from '~/mocks/browser'
import type { DecoratorFn } from '@storybook/react'
/** 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: DecoratorFn = (Story, { parameters }) => {
if (parameters.featureFlags) {
useFeatureFlags(parameters.featureFlags)
}
return <Story />
}