: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(hog-charts): add Metric storybook stories and snapshots (#61013)
Sam Penningtond973c49f698b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 51d590f9280e..937db7706d3e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -660,6 +660,22 @@ snapshots:hash: v1.k794b7964.e8aaf3e63d88d917b6511232aff85b4bf54f4c3b71fc267fde59a1170ba056a9.EL-FQ7Hqbd4FOdgbpZv2ynzzwJt2j6OQZkymgQXMC4Ucomponents-hogcharts-piechart--with-breakdown-labels--light:hash: v1.k794b7964.811f8e01cbeeb97d8319a76668d33864b6be08a2b8f270e5980fe951fafbc1bb.UoRHUDWOOnMGSCQcBN8D5TwfE6LL3IG58n0wUC_WOwo+ components-hogcharts-metric--default--dark:+ hash: v1.k794b7964.121acde0d2ffcbb2ea6657bdb2cd2666ba6d34528f3a0b6d61c517f3bfc0e690.G2RsZqN9I8j6BI-t453mJIL7Lld_JAhtO3FM5WSaV7A+ components-hogcharts-metric--default--light:+ hash: v1.k794b7964.8bd27e40dcb1bbbe2f2b4cb0f01fe04af3cf7b9816c7d735811db71e50c50824.xtUPK0ER9_UfV9lWaT3Y9hTzc97yLgrepJBIFffRQps+ components-hogcharts-metric--falling--dark:+ hash: v1.k794b7964.7a249706a02d3ecafb06f582dd4495c9c3f1a615debf421914f4cd6fd51b60ef.ZNY3dId9hCU0KmcNRCjEbey6sKytBJsRfv2u_30hJOU+ components-hogcharts-metric--falling--light:+ hash: v1.k794b7964.7223f07b305e81987250456c70b176fb0450056f87aa4b2e68aa2712ffbf3795.3aiuOFUzkCEZlYloBWWvbqGWLXasynQyeZ8M8ue-cVI+ components-hogcharts-metric--no-change--dark:+ hash: v1.k794b7964.7f692798e9fdec4e34d22d6237b910cf9d6d2c79bc8bfdd5f430ef4d6d159da9.92INHOJUd37OK1Mhaj-ZXrywofAqC27zHFETF_ZidJ8+ components-hogcharts-metric--no-change--light:+ hash: v1.k794b7964.a1029cc8a495d830890ee00d7ae7b9602e7c486695b5fe9dc49f1778cd3dcf37.wtoEorXIEYDVW-6Urx7d5IynJpP1mYb9ZDinvQr084M+ components-hogcharts-metric--number-only--dark:+ hash: v1.k794b7964.4360546d8053143c263d5315c0dd31ac95aa035467738b96fc24632e0b1fe1b2.p_5tW3kuA973BxYWWjwrQg2iwIyPbTYfbGaybWIwTZs+ components-hogcharts-metric--number-only--light:+ hash: v1.k794b7964.9e1fbd475ba802686d23440d747df99abc015757e7708d037f246464fd46a3f8.K1CGuG2R-VxLBu6HLU-jBXWJKH_49rGnbAUx1YnrTcQcomponents-hogcharts-referenceline--fill-sides--dark:hash: v1.k794b7964.c6b9d78f0423edc9a0baccf3dd9e05139aecb9387e8e3e5c32bcaec28663f279.zDKfyNa2u4-LWW40uD0XPkXVGUCnAZkfvJZI2TS0adAcomponents-hogcharts-referenceline--fill-sides--light:diff --git a/frontend/src/lib/hog-charts/blocks/Metric/Metric.stories.tsx b/frontend/src/lib/hog-charts/blocks/Metric/Metric.stories.tsxnew file mode 100644index 000000000000..7236b52d3d95--- /dev/null+++ b/frontend/src/lib/hog-charts/blocks/Metric/Metric.stories.tsx@@ -0,0 +1,92 @@+import { Meta, StoryObj } from '@storybook/react'++import { Stage, useReactiveTheme } from '../../story-helpers'+import { Metric } from './Metric'++const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']+const REVENUE = [4200, 5100, 4700, 5400, 6000, 5800, 6400, 6900, 7200, 7700, 8100, 8800]+const FALLING = [9800, 9200, 8600, 8400, 7700, 7300, 6900, 6500, 6000, 5400, 4800, 4200]++const meta: Meta = { title: 'Components/HogCharts/Metric', parameters: { layout: 'centered' } }+export default meta++type Story = StoryObj<{}>++export const Default: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={360} height={320}>+ <div className="rounded-xl border border-primary bg-surface-primary p-5 shadow-sm w-full h-full flex flex-col">+ <Metric+ title="Total Revenue"+ data={REVENUE}+ labels={MONTHS}+ theme={theme}+ color="#22d3ee"+ sparklineClassName="mt-4 -mx-5 -mb-5"+ formatValue={(v) => `US$${Math.round(v).toLocaleString()}`}+ />+ </div>+ </Stage>+ )+ },+}++export const Falling: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={360} height={320}>+ <div className="rounded-xl border border-primary bg-surface-primary p-5 shadow-sm w-full h-full flex flex-col">+ <Metric+ title="Active users"+ data={FALLING}+ labels={MONTHS}+ theme={theme}+ color="#fb7185"+ sparklineClassName="mt-4 -mx-5 -mb-5"+ formatValue={(v) => Math.round(v).toLocaleString()}+ />+ </div>+ </Stage>+ )+ },+}++export const NoChange: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={360} height={320}>+ <div className="rounded-xl border border-primary bg-surface-primary p-5 shadow-sm w-full h-full flex flex-col">+ <Metric+ title="Daily signups"+ data={REVENUE}+ labels={MONTHS}+ theme={theme}+ color="#22d3ee"+ showChange={false}+ sparklineClassName="mt-4 -mx-5 -mb-5"+ formatValue={(v) => Math.round(v).toLocaleString()}+ />+ </div>+ </Stage>+ )+ },+}++export const NumberOnly: Story = {+ render: () => (+ <Stage width={360} height={200}>+ <div className="rounded-xl border border-primary bg-surface-primary p-5 shadow-sm w-full h-full flex flex-col">+ <Metric+ title="Lifetime revenue"+ value={1_284_320}+ change={{ value: 8.4 }}+ formatValue={(v) => `US$${v.toLocaleString()}`}+ />+ </div>+ </Stage>+ ),+}