:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(storybook): remove MDX docs and refactor stories path config (#63862)
Rafael Audibertf3827e4015ac
diff --git a/common/storybook/.storybook/main.ts b/common/storybook/.storybook/main.tsindex 0c7995db6167..1d87dd96583b 100644--- a/common/storybook/.storybook/main.ts+++ b/common/storybook/.storybook/main.ts@@ -7,17 +7,15 @@ import { ModuleGraphPlugin } from './plugins/module-graph-plugin'// Repo root = three levels up from this file (common/storybook/.storybook/main.ts).const REPO_ROOT = path.resolve(__dirname, '..', '..', '..')+const createStoriesPathFor = (path: string): string => `../../../${path}/**/*.stories.@(js|jsx|ts|tsx)`+const config: StorybookConfig = {stories: [- '../../../frontend/src/**/*.mdx',- '../../../frontend/src/**/*.stories.@(js|jsx|ts|tsx)',- '../../../products/**/frontend/**/*.mdx',- '../../../products/**/frontend/**/*.stories.@(js|jsx|ts|tsx)',- '../../../products/**/mcp/**/*.mdx',- '../../../products/**/mcp/**/*.stories.@(js|jsx|ts|tsx)',- '../../../services/mcp/src/ui-apps/**/*.stories.@(js|jsx|ts|tsx)',- '../../../packages/quill/packages/charts/src/**/*.mdx',- '../../../packages/quill/packages/charts/src/**/*.stories.@(js|jsx|ts|tsx)',+ createStoriesPathFor('frontend/src'),+ createStoriesPathFor('products/**/frontend'),+ createStoriesPathFor('products/**/mcp/apps'),+ createStoriesPathFor('services/mcp/src/ui-apps'),+ createStoriesPathFor('packages/quill/packages/charts/src'),],addons: [diff --git a/frontend/src/lib/lemon-ui/LemonColor/LemonColor.mdx b/frontend/src/lib/lemon-ui/LemonColor/LemonColor.mdxdeleted file mode 100644index 3b3e2e62d9e1..000000000000--- a/frontend/src/lib/lemon-ui/LemonColor/LemonColor.mdx+++ /dev/null@@ -1,143 +0,0 @@-import { Meta } from '@storybook/blocks'--import { LemonTable } from '../LemonTable'-import { LemonColorButton } from './LemonColorButton'-import { LemonColorGlyph } from './LemonColorGlyph'-import { LemonColorPicker } from './LemonColorPicker'--<Meta title="Lemon UI/Lemon Color/Overview" />--# Lemon Color Components--## Data Color Tokens--Data color tokens (e.g., `preset-1`, `preset-2`, etc.) correspond to individual colors in the data color theme. The default data color theme includes 15 distinct color tokens, but custom themes can contain more or less colors. When the options are exhausted, the colors repeat from the beginning.--The purpose of these colors is to represent distinct data categories or series in visualizations such as charts, graphs, and diagrams. They ensure visual clarity and differentiation across multiple data points or groups.--### Default Theme Colors--<LemonTable- dataSource={[- 'data-color-1',- 'data-color-2',- 'data-color-3',- 'data-color-4',- 'data-color-5',- 'data-color-6',- 'data-color-7',- 'data-color-8',- 'data-color-9',- 'data-color-10',- 'data-color-11',- 'data-color-12',- 'data-color-13',- 'data-color-14',- 'data-color-15',- ].map((color) => ({ token: color.replace('data-color-', 'preset-'), name: color, color }))}- columns={[- {- title: 'Data Color Token',- key: 'token',- dataIndex: 'token',- render: (token) => token,- },- {- title: 'Color Variable Name',- key: 'name',- dataIndex: 'name',- render: (name) => name,- },- {- title: 'Color',- key: 'color',- dataIndex: 'color',- render: function RenderColor(color) {- return (- <div- className="border rounded h-8 w-8"- // eslint-disable-next-line react/forbid-dom-props- style={{ backgroundColor: `var(--${color})` }}- />- )- },- },- ]}-/>--## Components--### Usage Notes--- For data visualization and theme-aware colors, use `colorToken` props-- For custom colors, use the `color` prop with 6-digit hex values (e.g. '#FF0000')-- The `themeId` prop is only needed when using tokens--### LemonColorGlyph--Shows a circular glyph of the specified color.--```tsx-// Using a hex color-<LemonColorGlyph color="#FF0000" />--// Using a data token-<LemonColorGlyph colorToken="primary" themeId={1} />--// Small variant-<LemonColorGlyph color="#FF0000" size="small" />-```--### LemonColorButton--A button that displays a color glyph.--```tsx-// Using a hex color-<LemonColorButton color="#FF0000" />--// Using a data color token-<LemonColorButton colorToken="primary" themeId={1} />-```--### LemonColorPicker--A color picker.--```tsx-// Using hex colors-<LemonColorPicker- colors={['#FF0000', '#00FF00', '#0000FF']}- selectedColor="#FF0000"- onSelectColor={(color) => console.log(color)}-/>--// Using data color tokens-<LemonColorPicker- colorTokens={['primary', 'secondary', 'danger']}- selectedColorToken="primary"- onSelectColorToken={(token) => console.log(token)}- themeId={1}-/>-```--### LemonColorList--A horizontal list of color options.--```tsx-// Using hex colors-<LemonColorList- colors={['#FF0000', '#00FF00', '#0000FF']}- selectedColor="#FF0000"- onSelectColor={(color) => console.log(color)}-/>--// Using data color tokens-<LemonColorList- colorTokens={['primary', 'secondary', 'danger']}- selectedColorToken="primary"- onSelectColorToken={(token) => console.log(token)}- themeId={1}-/>-```diff --git a/frontend/src/stories/Hello.mdx b/frontend/src/stories/Hello.mdxdeleted file mode 100644index 6b20cabda174..000000000000--- a/frontend/src/stories/Hello.mdx+++ /dev/null@@ -1,34 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" Hello" />----# Hello from Storybook--## Here you will find--- **Components** - Storybook is our component library. Before building a new component, check here first- [and use](/docs/how-to-use-components--page) an existing one if possible.- When building a new component, [create a story](/docs/how-to-create-stories--page#component-stories) for it.- Have a look at the [TaxonomicPopover](/docs/filters-taxonomicpopover--taxonomic-string-popover-one-category) or- [LemonSwitch](/docs/components-lemon-switch--lemon-switch) for example.-- **Scenes** - Most scenes in PostHog, with data, accessible with a click, no backend required. Including- [all](/story/scenes-app-insights--trends-line-breakdown), [types](/story/scenes-app-insights--lifecycle),- [of](/story/scenes-app-insights--trends-pie-breakdown), [insights](/story/scenes-app-insights--funnel-left-to-right-breakdown)- and even [the toolbar](/story/scenes-other-toolbar--authenticated). There's also a [guide on building new scenes](/docs/how-to-build-a-scene--page)- if you're into that kind of stuff.-- **Forms** - Coming sooner than you expect: reusable components and [methodology for building forms](/docs/how-to-build-a-form--page) with React + Kea.--## Help needed--- [Missing components](/docs/missing-components--page)-- [Missing scenes](/docs/missing-scenes--page)--## Running locally--To run storybook locally, run `pnpm storybook`. It'll open on [http://localhost:6006/](http://localhost:6006/)--## Hot tips--- When you're in a [scene story](/story/scenes-app-dashboard--edit), hit "a" and click "Story" to see its source.diff --git a/frontend/src/stories/How to add tabs to a scene.mdx b/frontend/src/stories/How to add tabs to a scene.mdxdeleted file mode 100644index 807fd13b679f..000000000000--- a/frontend/src/stories/How to add tabs to a scene.mdx+++ /dev/null@@ -1,131 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title="How to add tabs to a scene?" />--# How to add tabs to a scene?--This guide follows on from ["How to build a scene"](/docs/how-to-build-a-scene--page) – we'll be adding tabs to that guide's Dashboards scene.--1. Add an enum to `frontend/src/types.ts` to define the tabs:--```ts title="frontend/src/types.ts"-export enum DashboardsTabs {- First = 'first',- Second = 'second',-}-```--2. Update the URL in `frontend/src/scenes/urls.ts` to handle tabs:--```ts title="frontend/src/scenes/urls.ts"-dashboards: (tab: DashboardsTabs = DashboardsTabs.First): string => `/dashboards/${tab}`-```--3. Add entries to routes per tab in `frontend/src/scenes/scenes.ts`:--```ts title="frontend/src/scenes/scenes.ts"- // One entry for every available tab- ...Object.fromEntries(- Object.values(DashboardsTabs).map((tab) => [urls.dashboards(tab), Scene.Dashboards])- ) as Record<string, Scene>,-```--4. Update `dashboardsLogic` to handle tab changes in `frontend/src/scenes/dashboards/dashboardsLogic.ts`:--```ts title="frontend/src/scenes/dashboards/dashboardsLogic.ts"-import { actions, kea, path, reducers, selectors } from 'kea'-import { actionToUrl, urlToAction } from 'kea-router'--import { urls } from 'scenes/urls'--import { Breadcrumb, DashboardsTabs } from '~/types'--export const DASHBOARDS_TAB_TO_NAME: Record<DashboardsTabs, string> = {- [DashboardsTabs.First]: 'First',- [DashboardsTabs.Second]: 'Second',-}--export const dashboardsLogic = kea([- path(['scenes', 'dashboard', 'dashboardsLogic']),- actions({- setCurrentTab: (tab: DashboardsTabs = DashboardsTabs.First) => ({ tab }),- }),- reducers({- currentTab: [- DashboardsTabs.First as DashboardsTabs,- {- setCurrentTab: (_, { tab }) => tab,- },- ],- }),- selectors(() => ({- breadcrumbs: [- // Optional if you'd like the breadcrumbs to show the current tab- (s) => [s.currentTab],- (tab): Breadcrumb[] => {- const breadcrumbs: Breadcrumb[] = [{ name: 'Dashboards' }]- breadcrumbs.push({- name: DASHBOARDS_TAB_TO_NAME[tab],- })-- return breadcrumbs- },- ],- })),- actionToUrl(({ values }) => {- return {- setCurrentTab: () => [urls.dashboards(values.currentTab)],- }- }),- urlToAction(({ actions, values }) => ({- '/dashboards/:tab': ({ tab }) => {- if (tab !== values.currentTab) {- actions.setCurrentTab(tab as DashboardsTabs)- }- },- })),-])-```--5. Update `frontend/src/scenes/dashboards/Dashboards.tsx` to render the tabs:--```tsx title="frontend/src/scenes/dashboards/Dashboards.tsx"-import { useValues } from 'kea'-import { router } from 'kea-router'--import { LemonTabs } from 'lib/lemon-ui/LemonTabs/LemonTabs'-import { SceneExport } from 'scenes/sceneTypes'-import { urls } from 'scenes/urls'--import { DashboardsTabs } from '~/types'--import { dashboardsLogic, humanFriendlyTabName } from './dashboardsLogic'--const DASHBOARDS_TAB_TO_CONTENT: Record<DashboardsTabs, JSX.Element> = {- [DashboardsTabs.First]: <div>First tab content</div>,- [DashboardsTabs.Second]: <div>Second tab content</div>,-}--export const scene: SceneExport = {- component: Dashboards,- logic: dashboardsLogic,-}--export function Dashboards(): JSX.Element {- const { currentTab } = useValues(dashboardsLogic)-- return (- <div>- <LemonTabs- activeKey={currentTab}- onChange={(tab) => router.actions.push(urls.dashboards(tab as DashboardsTabs))}- tabs={Object.values(DashboardsTabs).map((tab) => ({- label: DASHBOARDS_TAB_TO_NAME[tab],- key: tab,- content: DASHBOARDS_TAB_TO_CONTENT[tab],- }))}- />- </div>- )-}-```diff --git a/frontend/src/stories/How to build a form.mdx b/frontend/src/stories/How to build a form.mdxdeleted file mode 100644index 1376aa880f98..000000000000--- a/frontend/src/stories/How to build a form.mdx+++ /dev/null@@ -1,181 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" How to build a form?" />--# How to build a form?--The steps below work, but may change at any moment. All feedback and suggestions welcome!--## 1. Start with the data--You should always [think data first](https://keajs.org/blog/data-first-frontend-revolution/). Forms are no exception.-Start by considering which data in which logic you will to expose to a form.--For example, this `featureFlagLogic` already has a loader called `featureFlag`. Let's use that in a form by-creating a new `forms` object:--```ts-export const featureFlagLogic = kea<featureFlagLogicType<FeatureFlagLogicProps>>({- path: (key) => ['scenes', 'feature-flags', 'featureFlagLogic', key],- props: {} as FeatureFlagLogicProps,- key: ({ id }) => id ?? 'new',-- loaders: ({ values, props }) => ({- featureFlag: [- { ...NEW_FLAG } as FeatureFlagModel,- {- loadFeatureFlag: () => api.get(`api/projects/${values.currentProjectId}/feature_flags/${props.id}`),- },- ],- }),-- forms: ({ actions }) => ({- featureFlag: {- // not really needed again since loader already defines it- defaults: { ...NEW_FLAG } as FeatureFlagModel,-- // sync validation, will be shown as errors in the form- errors: (featureFlag) => ({- key: !featureFlag.key ? 'Must have a key' : undefined,- }),-- // called on the form's onSubmit, unless a validation fails- submit: async (featureFlag, breakpoint) => {- // eslint-disable-next-line @typescript-eslint/no-unused-vars- const { created_at, id, ...flag } = featureFlag- const newFeatureFlag = updatedFlag.id- ? await api.update(`api/projects/${values.currentProjectId}/feature_flags/${updatedFlag.id}`, flag)- : await api.create(`api/projects/${values.currentProjectId}/feature_flags`, flag)- breakpoint()- actions.setFeatureFlagValues(newFeatureFlag)- lemonToast.success('Feature flag saved')- featureFlagsLogic.findMounted()?.actions.updateFlag(featureFlag)- router.actions.replace(urls.featureFlag(featureFlag.id))- },- },- }),-})-```--The code above will add [a few actions, reducers and selectors](https://github.com/keajs/kea-forms/blob/main/src/plugin.ts#L24-L139)-to `featureFlagLogic`. This is the list as of kea-forms v0.2.1:--```tsx-export interface featureFlagLogicType extends Logic {- actions: {- // kea-loaders- loadFeatureFlag: () => void- loadFeatureFlagSuccess: (featureFlag: any, payload?: any) => void- loadFeatureFlagFailure: (error: string, errorObject?: any) => void-- // kea-forms- setFeatureFlagValue: (key: FieldName, value: any) => void- setFeatureFlagValues: (values: DeepPartial<FeatureFlagType>) => void- touchFeatureFlagField: (key: string) => void- resetFeatureFlag: (values?: FeatureFlagType) => void- submitFeatureFlag: () => void- submitFeatureFlagRequest: (featureFlag: FeatureFlagType) => void- submitFeatureFlagSuccess: (featureFlag: FeatureFlagType) => void- submitFeatureFlagFailure: (error: Error) => void- }- values: {- // kea-loaders- featureFlag: FeatureFlagType- featureFlagLoading: boolean-- // kea-forms- isFeatureFlagSubmitting: boolean- showFeatureFlagErrors: boolean- featureFlagChanged: boolean- featureFlagTouches: Record<string, boolean>- }-}-```--The latest documentation can be found here: https://github.com/keajs/kea-forms--## 2. Build the interface--With the logic in order, you may now pull in the `<Form />`, `<Field />` and `<Group />` tags to build your form.--```tsx-import { Form, Group } from 'kea-forms'-import { Field } from 'lib/forms/Field'-import { featureFlagLogic, FeatureFlagLogicProps } from './featureFlagLogic'--export function FeatureFlag({ id }: { id?: string } = {}): JSX.Element {- const logicProps: FeatureFlagLogicProps = { id: id ? parseInt(id) : 'new' }- const {- featureFlag, // the values in the object are the values in the form- isFeatureFlagSubmitting, // if the submit action is doing something- } = useValues(featureFlagLogic(logicProps))- const {- submitFeatureFlag, // if we need to submit it outside the normal form submit- setFeatureFlagValue, // if we need to update any field outside the <Field /> tags- } = useActions(featureFlagLogic(logicProps))-- return (- <Form- logic={featureFlagLogic}- props={logicProps}- formKey="featureFlag"- enableFormOnSubmit // makes the HTML "submit" button work directly- >- <Field name="active">- {/* value, onChange, onChangeEvent, name, label, id */}- {({ value, onChange }) => (- <LemonSwitch- checked={value}- onChange={onChange}- label={- value ? (- <span className="text-success">Enabled</span>- ) : (- <span className="text-danger">Disabled</span>- )- }- />- )}- </Field>-- <Field name="name" label="Description">- <LemonTextArea- // value and onChange added automatically to Lemon components- className="ph-ignore-input"- data-attr="feature-flag-description"- placeholder="Adding a helpful description can ensure others know what this feature is for."- />- </Field>-- {featureFlag?.filters?.multivariate?.variants?.map((_, index) => (- // using <Group /> to scope the next fields- <Group key={index} name={['filters', 'multivariate', 'variants', index]}>- <Field name="name">- {/* This will update featureFlag.filters.multivariate.variants[index].name */}- {/* If you don't specify ({ value, onChange }) => (), we add these two props automatically */}- <LemonInput- data-attr="feature-flag-variant-name"- className="ph-ignore-input"- placeholder="Description"- />- </Form.Item>- </Group>- )}-- <LemonButton- loading={isFeatureFlagSubmitting}- icon={<SaveOutlined />}- htmlType="submit"- type="primary"- data-attr="feature-flag-submit-bottom"- >- Save changes- </LemonButton>- </Form>- )-}-```--## 3. Select your components--The (WIP) list of form elements in storybook should serve as your guide.diff --git a/frontend/src/stories/How to build a scene.mdx b/frontend/src/stories/How to build a scene.mdxdeleted file mode 100644index 8c81e018283a..000000000000--- a/frontend/src/stories/How to build a scene.mdx+++ /dev/null@@ -1,286 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" How to build a scene?" />--# How to build a scene?--If you want to add a new scene in the PostHog App frontend, here are 7 easy steps for fun and profit.--But first, you must answer one question: Does your scene depend on an `id` in the URL, like `/dashboard/:id`?--## Option A: I'm buliding a global scene that does not depend on an `id` in the URL--### 1. Create the component, logic and styles--Create a component like: `frontend/src/scenes/dashboard/Dashboards.tsx`--```ts-import { dashboardsLogic } from './dashboardsLogic'-import { SceneExport } from 'scenes/sceneTypes'-import { useValues } from 'kea'--export function Dashboards (): JSX.Element {- const {- counter- } = useValues(dashboardsLogic)-- return (- // TODO: consolidate on a recommended naming convention- <div className='dashboard-scene'>- Dashboard Scene {counter}!- </div>- )-}--export const scene: SceneExport = {- component: Dashboards,- logic: dashboardsLogic,-}-```--Create the logic: `frontend/src/scenes/dashboard/dashboardsLogic.tsx`--```ts-import { kea, path, reducers } from 'kea'--export const dashboardsLogic = kea([- path(['scenes', 'dashboard', 'dashboardsLogic']),- reducers({- counter: [1, {}],- }),-])-```--Create the styles `frontend/src/scenes/dashboard/Dashboards.scss`.--```ts-.dashboards-scene {- // put all your styles inside this scope, as everything is global-}-```--Run kea type generation and check, which will created `dashboardsLogicType.ts` and update imports in `dashboardsLogic.tsx`--```bash-pnpm typegen:write && pnpm typescript:check-```--### 2. Add a URL function--in `frontend/src/scenes/urls.ts`--```ts-export const urls = {- dashboards: () => `/dashboard`,-}-```--### 3. Add a scene to the enum--in `frontend/src/scenes/sceneTypes.ts`--```ts-export enum Scene {- Dashboards = 'Dashboards',-}-```--### 4. Add a scene configuration and a route to scene mapping--in `frontend/src/scenes/scenes.ts`--```ts-export const sceneConfigurations: Partial<Record<Scene, SceneConfig>> = {- [Scene.Dashboards]: {- projectBased: true,- name: 'Dashboards',- },-}--export const routes: Record<string, Scene> = {- [urls.dashboards()]: Scene.Dashboards,-}-```--### 5. Add a scene import--in `frontend/src/scenes/appScenes.ts`--```ts-export const appScenes: Record<Scene, () => any> = {- [Scene.Dashboards]: () => import('./dashboard/Dashboards'),-}-```--## Option B: My scene depends on an `id` in the URL (`/dashboard/:id`)--### 1. Create the component, logic and styles--Create a component like: `frontend/src/scenes/dashboard/Dashboard.tsx`--```ts-import { dashboardLogic } from './dashboardLogic'-import { SceneExport } from 'scenes/sceneTypes'-import { useValues } from 'kea'--export const scene: SceneExport = {- component: Dashboard,- logic: dashboardLogic,- // paramsToProps - Convert url _string_ params to logic props.- // This mounts the right logic with turbo mode before the component renders.- // This wraps the scene's logic in <BindLogic />- paramsToProps: ({ params: {id} }:{ params: { id?: string }}) => ({ id: id ? parseInt(id) : 'new' }),-}--export function Dashboard ({ id }: { id?: string } = {}): JSX.Element {- // dashboardLogic is automatically bound to the props above with BindLogic- const {- counter- } = useValues(dashboardLogic)-- return (- // TODO: consolidate on a recommended naming convention- <div className='dashboard-scene'>- Dashboard Scene {id} {counter}!- </div>- )-}-```--Create the logic: `frontend/src/scenes/dashboard/dashboardLogic.tsx`--```ts-import { kea, key, path, props, reducers } from 'kea'--export interface DashboardLogicProps {- id: number | 'new'-}--export const dashboardLogic = kea([- props({} as DashboardLogicProps),- key(({ id }) => id),- path((id) => ['scenes', 'dashboard', 'dashboardLogic', id]),- reducers({- counter: [1, {}],- }),-])-```--Create the styles `frontend/src/scenes/dashboard/Dashboard.scss`.--```ts-.dashboard-scene {- // put all your styles inside this scope, as everything is global-}-```--Run kea type generation and check, which will created `dashboardLogicType.ts` and update imports in `dashboardLogic.tsx`--```bash-pnpm typegen:write && pnpm typescript:check-```--### 2. Add a URL function--in `frontend/src/scenes/urls.ts`--```ts-export const urls = {- dashboard: (id: string | number) => `/dashboard{id ? `/${id}` : ''}`,-}-```--### 3. Add a scene to the enum--in `frontend/src/scenes/sceneTypes.ts`--```ts-export enum Scene {- Dashboard = 'Dashboard',-}-```--### 4. Add a scene configuration and a route to scene mapping--in `frontend/src/scenes/scenes.ts`--```ts-export const sceneConfigurations: Partial<Record<Scene, SceneConfig>> = {- [Scene.Dashboard]: {- projectBased: true,- name: 'Dashboard',- },-}--export const routes: Record<string, Scene> = {- // this `:id` gets used in "params" in "paramsToProps" and passed to the <Dashboard /> component- [urls.dashboard(':id')]: Scene.Dashboard,-}-```--### 5. Add a scene import--in `frontend/src/scenes/appScenes.ts`--```ts-export const appScenes: Record<Scene, () => any> = {- [Scene.Dashboard]: () => import('./dashboard/Dashboard'),-}-```--## 6. Create a story for your scene--In the same folder as your component, create a file like `frontend/src/scenes/dashboard/Dashboard.stories.tsx`.-If you need a lot of `.json` files for mocked data, create a `__mocks__` subdirectory for those files, just like you would with `jest`.--```tsx-import { Meta, StoryObj } from '@storybook/react'-import { router } from 'kea-router'-import { useEffect } from 'react'--import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'-import { App } from 'scenes/App'-import { urls } from 'scenes/urls'--import { mswDecorator, useStorybookMocks } from '~/mocks/browser'--export default {- title: 'Scenes-App/Dashboard',- decorators: [- // mocks used by all stories in this file- mswDecorator({- get: {- '/api/projects/1/dashboards/': require('./__mocks__/dashboards.json'),- '/api/projects/1/dashboards/1/': require('./__mocks__/dashboard1.json'),- '/api/projects/1/dashboards/1/collaborators/': [],- },- }),- ],- // NB! These `parameters` only apply for Scene stories.- parameters: { layout: 'fullscreen', options: { showPanel: false }, viewMode: 'story' }, // scene mode-} as Meta--export function NewDashboard(): JSX.Element {- // mocks used only in this story- useStorybookMocks({- get: { '/api/projects/dashboard/2/': require('./__mocks__/dashboard2.json') },- })-- useOnMountEffect(() => {- // change the URL- router.actions.push(urls.dashboard(2))- // call various other actions to set the initial state- newDashboardLogic.actions.showNewDashboardModal()- })-- return <App />-}-```--## 7. Add some components--Read next:--- [How to use components](/docs/how-to-use-components--page)-- [How to build a form](/docs/how-to-build-a-form--page)-- [How to add tabs to a scene](/docs/how-to-add-tabs-to-a-scene--page)diff --git a/frontend/src/stories/How to create stories guide.mdx b/frontend/src/stories/How to create stories guide.mdxdeleted file mode 100644index 5cf6fd3fbef7..000000000000--- a/frontend/src/stories/How to create stories guide.mdx+++ /dev/null@@ -1,86 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" How to create stories?" />--# How to create stories?--There are three types of stories:--- Markdown stories-- Scene stories-- Component stories--Choose the type most suited for your case.--## Markdown stories--Documents, such as the one you're reading, go in `frontend/src/stories/*.stories.mdx`.--Tip: you may want to add a space in front of the title for the doc to be ordered before other components in the sidebar.--```md-<!-- frontend/src/stories/New Page.stories.mdx -->--import { Meta } from '@storybook/blocks';--<Meta title=" New Page" />--# Page Title--Write your content here...-```--## Component stories--There are a few differences between component and scene stories:--- Pass a `component` to the default export, for Storybook to create a table with the component's props.-- Remove the custom `parameters` object that is in use in scene stories (that defaults the scene to open in "canvas" mode).-- Add any changes to arguments in [`argTypes`](https://storybook.js.org/docs/react/api/argtypes)--```tsx-// frontend/src/lib/lemon-ui/LemonSwitch/LemonSwitch.stories.tsx-import { Meta, StoryObj } from '@storybook/react'--import { LemonSwitch, LemonSwitchProps } from './LemonSwitch'--type Story = StoryObj<LemonSwitchProps>-const meta: Meta<LemonSwitchProps> = {- title: 'Lemon UI/Lemon Switch',- component: LemonSwitch,- argTypes: {- loading: {- control: {- type: 'boolean',- },- },- label: {- name: 'label',- type: { name: 'string', required: false },- defaultValue: 'Hello',- description: 'demo description',- table: {- type: { summary: 'string' },- defaultValue: { summary: 'Hello' },- },- control: {- type: 'text',- },- },- },- tags: ['autodocs'],-}-export default meta--export function LemonSwitch_(props: LemonSwitchProps): JSX.Element {- const [isChecked, setIsChecked] = useState(false)-- return (- <LemonSwitch {...props} checked={props.checked !== undefined ? props.checked : isChecked} onChange={setIsChecked} />- )-}-```--## Scene stories--[Read more here](/docs/how-to-build-a-scene--page#6-create-a-story-for-your-scene)diff --git a/frontend/src/stories/How to mock requests.mdx b/frontend/src/stories/How to mock requests.mdxdeleted file mode 100644index 82eeced9c999..000000000000--- a/frontend/src/stories/How to mock requests.mdx+++ /dev/null@@ -1,80 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" How to mock requests?" />--# How to mock requests?--## MockServiceWorker--- We use an abstraction over [MockServiceWorker](https://mswjs.io/) to provide API mocks.-- This abstraction along with the- [default mocks](https://github.com/PostHog/posthog/blob/master/frontend/src/mocks/handlers.ts#L7) are shared between storybook and jest tests.--## Specifying mocks--### Where to call--To specify mocked API calls in a story, use one of these two options:--```tsx-// SomeScene.stories.tsx-import { mswDecorator, useStorybookMocks } from '~/mocks/browser'--export default {- title: 'Scenes-App/Some Scene',- decorators: [- // applies for all stories in file- mswDecorator(MOCK_ARGUMENTS),- ],-}--export function Dashboard(): JSX.Element {- // applies to just this story- useStorybookMocks(MOCK_ARGUMENTS)- return <div />-}-```--### Arguments--The `MOCK_ARGUMENTS` take one of these formats:--```tsx-// you can the four HTTP methods-useStorybookMocks({- get: {},- post: {},- patch: {},- delete: {},-})--// and any of these styles-useStorybookMocks({- get: {- // return a 200 success with the object passed here- '/api/endpoint': { results: [], success: true }-- // return a 200 success after a 100ms delay, using msw-s ctx- '/api/other_endpoint': (_, __, ctx) => [- ctx.delay(100),- ctx.status(200),- ctx.json({ results: [], success: true })- ]-- // shorthand for status + json- '/api/status_shorthand': () => [500, { error: 'Error text' }]-- // complicated param handling- '/api/environments/:team_id/insights': (req, _, ctx) => {- const team = req.params['team']- const shortId = req.url.searchParams.get('short_id')- if (shortId === 'my_insight') {- return [200, { result: [{ ...insightJson, team_id: team }] }]- }- return [500, null]- }-- },-})--```diff --git a/frontend/src/stories/How to use components.mdx b/frontend/src/stories/How to use components.mdxdeleted file mode 100644index aabc7e1be303..000000000000--- a/frontend/src/stories/How to use components.mdx+++ /dev/null@@ -1,26 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" How to use components?" />--# How to use components?--We're trying to figure things out. This is a work in progress.--Topics not covered here:--- [How to build a new scene](/docs/how-to-build-a-scene--page)-- [How to build a form](/docs/how-to-build-a-form--page)-- [How does Kea work](https://keajs.org/docs/guide/concepts) and what's our component <-> logic code split.--Topics to cover here:--- Everything after "[how to build a scene](/docs/how-to-build-a-scene--page)" and everything before "[how to build a form](/docs/how-to-build-a-form--page)"-- Overview of most often used components-- Do we use any kind of layout or grid system? If so, what kind and how do I make a row? Do I always need to nest- elements inside container elements?-- What's our story for typography and paragraphs?-- How much space should be kept between components? What assures this?-- Can I nest components? Can I put a lemon table in a lemon table in a lemon table in a lemon switch's label?-- What about common CSS variables, states (primary, secondary, danger, etc), how do I modify other components or states?-- What CSS conventions do we use? Can I install my own css framework for that one new button?-- Everything with plenty of example code to copy.diff --git a/frontend/src/stories/Lemon UI.mdx b/frontend/src/stories/Lemon UI.mdxdeleted file mode 100644index e11e110cfb12..000000000000--- a/frontend/src/stories/Lemon UI.mdx+++ /dev/null@@ -1,41 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title="Lemon UI/Overview" />--# Lemon UI--Lemon UI is a suite of building blocks powering PostHog's frontend. These components are abstract in nature so they-can be used in any context, and are made to fit together. In this section you can find helpful samples, along with-documentation of available parameters. All the other Storybook sections depend on this one.--## Transition from Ant Design--Lemon UI has grown as a replacement for [Ant Design](https://ant.design/), from which we've started transitioning away-after onboarding our first product designer, Chris. The quality of our UI has been steadily going up since then,-but the transition process is not complete yet.--**Your** awareness is needed for us to transition sucessfully. 💪 Please **DO NOT** use the following Ant components when building new UI:--- `Button` – instead go for `LemonButton`-- `Select` – instead go for `LemonSelect`-- `Input`, `Input.Password`, `Input.Search` – instead go for `LemonInput`-- `Input.TextArea` – instead go for `LemonTextArea`-- `Table` – instead go for `LemonTable`-- `Checkbox` – instead go for `LemonCheckbox`-- `Spin` – instead go for `Spinner`-- `Alert` – instead go for `LemonBanner`-- `Typography` – just use HTML elements-- `Modal` – instead go for `LemonModal`-- `Divider` – instead go for `LemonDivider`-- `Row` – instead go for `LemonRow` (for standard rows of content) or roll your own `display: flex` as needed (for general layout)-- `Col` – roll your own `display: flex` as needed--## Lemon principles--- Layout is based on an 8px by 8px grid, so element dimensions/paddings/margins should be multiples of 8px (0.5rem)--## Utility CSS classes--To simplify styling of elements and remove the need for custom CSS as much as possible, we have a range of Utility CSS classes, modelled off of the popular Tailwind. Tailwind itself is something we decided not to include directly at this point in time, but we aim to keep the internal system as close to that of Tailwind as possible to ensure a simple mental model for contributors as well as keeping the door open to migrating to it in the future.--As we are sticking as close to Tailwind as possible - you can use the fantastic [TailwindCSS Docs](https://tailwindcss.com/) to search for any util you are interested in (press `cmd+k` to bring up a quick search on their site). There will of course be many functions we haven't incorporated yet but this at least acts as starting point for documentation and a reference for implementation.diff --git a/frontend/src/stories/Missing components.mdx b/frontend/src/stories/Missing components.mdxdeleted file mode 100644index 92768f445c39..000000000000--- a/frontend/src/stories/Missing components.mdx+++ /dev/null@@ -1,11 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" Missing components" />--# Missing components--A lot of components are missing. TODO for now:--1. Make an overview of what is there in the `lib/components` folder, and `lib/` in general.-2. Make a list of components that need stories-3. Create those storiesdiff --git a/frontend/src/stories/Missing scenes.mdx b/frontend/src/stories/Missing scenes.mdxdeleted file mode 100644index 7bc367bd1b7a..000000000000--- a/frontend/src/stories/Missing scenes.mdx+++ /dev/null@@ -1,28 +0,0 @@-import { Meta } from '@storybook/blocks'--<Meta title=" Missing scenes" />--# Missing scenes--The following scenes are missing. Please help add them:--- Dashboards- - List- - Dashboards-- Insights- - Funnels- - Empty state with bad exclusion filters- - Correlation Results- - Property Correlation Results- - Skewed Funnel Results-- Recordings- - View a recording-- Experiments-- Data Managmenet-- Persons & Groups-- Cohorts-- Annotations-- Plugins-- Toolbar detailed views-- Project settings-- Organization settingsdiff --git a/frontend/vite.config.mts b/frontend/vite.config.mtsindex 5436d599a512..2c3cb31cc99e 100644--- a/frontend/vite.config.mts+++ b/frontend/vite.config.mts@@ -59,7 +59,6 @@ export default defineConfig(({ mode }) => {models: resolve(__dirname, 'src/models'),mocks: resolve(__dirname, 'src/mocks'),exporter: resolve(__dirname, 'src/exporter'),- stories: resolve(__dirname, 'src/stories'),types: resolve(__dirname, 'src/types.ts'),// @posthog/lemon-ui aliases'@posthog/lemon-ui': resolve(__dirname, '@posthog/lemon-ui/src/index'),