mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 00:46:45 +01:00
29 lines
668 B
TypeScript
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 />
|
|
}
|