|
| 1 | +import { SessionFooter } from "@posthog/ui/features/sessions/components/SessionFooter"; |
| 2 | +import type { ContextUsage } from "@posthog/ui/features/sessions/hooks/useContextUsage"; |
| 3 | +import type { Meta, StoryObj } from "@storybook/react-vite"; |
| 4 | + |
| 5 | +const meta: Meta<typeof SessionFooter> = { |
| 6 | + title: "Sessions/SessionFooter", |
| 7 | + component: SessionFooter, |
| 8 | + parameters: { |
| 9 | + layout: "padded", |
| 10 | + }, |
| 11 | +}; |
| 12 | + |
| 13 | +export default meta; |
| 14 | +type Story = StoryObj<typeof SessionFooter>; |
| 15 | + |
| 16 | +const usage: ContextUsage = { |
| 17 | + used: 788_000, |
| 18 | + size: 1_000_000, |
| 19 | + percentage: 79, |
| 20 | + cost: null, |
| 21 | + breakdown: null, |
| 22 | +}; |
| 23 | + |
| 24 | +const generatingArgs = { |
| 25 | + isPromptPending: true, |
| 26 | + promptStartedAt: Date.now() - 5_400, |
| 27 | + lastGenerationDuration: null, |
| 28 | + usage, |
| 29 | +}; |
| 30 | + |
| 31 | +/** Wraps the footer in fixed-width boxes so narrow panes are easy to eyeball. */ |
| 32 | +function AtWidths({ args }: { args: Parameters<typeof SessionFooter>[0] }) { |
| 33 | + return ( |
| 34 | + <div className="flex flex-col gap-4"> |
| 35 | + {[720, 480, 400, 340, 280, 220].map((width) => ( |
| 36 | + <div key={width}> |
| 37 | + <div className="mb-1 text-[11px] text-gray-9">{width}px</div> |
| 38 | + <div |
| 39 | + className="rounded border border-gray-6 border-dashed px-2" |
| 40 | + style={{ width }} |
| 41 | + > |
| 42 | + <SessionFooter {...args} /> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + ))} |
| 46 | + </div> |
| 47 | + ); |
| 48 | +} |
| 49 | + |
| 50 | +export const GeneratingAtNarrowWidths: Story = { |
| 51 | + args: generatingArgs, |
| 52 | + render: (args) => <AtWidths args={args} />, |
| 53 | +}; |
| 54 | + |
| 55 | +export const GeneratingWithQueueAtNarrowWidths: Story = { |
| 56 | + args: { ...generatingArgs, queuedCount: 2 }, |
| 57 | + render: (args) => <AtWidths args={args} />, |
| 58 | +}; |
| 59 | + |
| 60 | +export const AwaitingPermissionAtNarrowWidths: Story = { |
| 61 | + args: { ...generatingArgs, hasPendingPermission: true }, |
| 62 | + render: (args) => <AtWidths args={args} />, |
| 63 | +}; |
| 64 | + |
| 65 | +export const IdleAtNarrowWidths: Story = { |
| 66 | + args: { |
| 67 | + isPromptPending: false, |
| 68 | + lastGenerationDuration: 331_000, |
| 69 | + usage, |
| 70 | + }, |
| 71 | + render: (args) => <AtWidths args={args} />, |
| 72 | +}; |
0 commit comments