0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 17:24:15 +01:00
posthog/.storybook/preview.tsx
Marius Andra c271eb99a5
feat(storybook): cleanup volume 1 (#9033)
* rearrange stories

* fix bug in storybook with mock data

* convert to TS, fix static path deprecation

* wrap all scenes with KeaStory, deprecate getReduxState

* remove old text

* don't complain about postcss

* remove ApiSelector, revert to ".js" main

* preview ".ts"

* fix msw

* move kea story

* fix urls

* add /decide handler

* mount logics that are there on app

* reduce boilerplate

* refactor history list storybook api

* separate data
2022-03-15 17:36:51 +01:00

55 lines
1.5 KiB
TypeScript

import * as React from 'react'
import '~/styles'
import { worker } from '~/mocks/browser'
import { loadPostHogJS } from '~/loadPostHogJS'
import { KeaStory } from './kea-story'
const setupMsw = () => {
// Make sure the msw worker is started
worker.start()
;(window as any).__mockServiceWorker = worker
}
setupMsw()
const setupPosthogJs = () => {
// Make sure we don't hit production posthog. We want to control requests to,
// e.g. `/decide/` for feature flags
window.JS_POSTHOG_HOST = window.location.origin
// We don't be doing any authn so we can just use a fake key
window.JS_POSTHOG_API_KEY = 'dummy-key'
loadPostHogJS()
}
setupPosthogJs()
// Setup storybook global parameters. See https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
// opt in to panels in your story by overridding `export const parameters`
showPanel: false,
},
}
// Setup storybook global decorators. See https://storybook.js.org/docs/react/writing-stories/decorators#global-decorators
export const decorators = [
// Make sure the msw service worker is started, and reset the handlers to
// defaults.
(Story: any) => {
return (
<KeaStory>
<Story />
</KeaStory>
)
},
]