import { expect, within } from "storybook/test"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { Box } from "../containers/Box"; import { Paragraph, Text } from "../primitives/Text"; import { Story } from "../story-components/Story"; import { Code } from "./Code"; type ThisStory = StoryObj; export default { title: "alouette/Data/Code", component: Code, parameters: { componentSubtitle: "Inline code — a mono fragment on the highlight layer, sized by the text it sits in", }, argTypes: { children: { description: "The code fragment", control: "text" }, }, } satisfies Meta; export const CodePreviewStory: ThisStory = { name: "Code Preview", parameters: { layout: "padded", chromatic: { disableSnapshot: true }, }, args: { children: "pnpm build" }, render: (args) => , }; export const CodeVariantsStory: ThisStory = { name: "Code Variants", render: () => ( npx vitest run Run pnpm --filter alouette build:css after editing{" "} paletteSpecs.ts, never edit the generated CSS. text-xs — generateTheme() text-base — generateTheme() text-xl — generateTheme() A fragment can still take a class:{" "} --color-accent or{" "} --color-muted. The highlight layer keeps the fragment readable on a Surface:{" "} useCurrentTheme() ), }; export const CodeTestsStory: ThisStory = { name: "Code Tests", render: () => ( Install with pnpm add alouette. ), play: async ({ canvasElement }) => { const canvas = within(canvasElement); const code = canvas.getByText("pnpm add alouette"); // react-native-web maps role="code" onto a real element, nested in // the

Paragraph renders. await expect(code.tagName).toBe("CODE"); await expect(code.closest("p")).not.toBeNull(); }, };