import { expect, within } from "storybook/test"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { Box } from "../containers/Box"; import { Story } from "../story-components/Story"; import { Paragraph, Text } from "./Text"; type ThisStory = StoryObj; export default { title: "alouette/Primitives/Text", component: Text, parameters: { componentSubtitle: "A foundational text component that provides consistent text styling across the application", docs: { description: { component: `### Usage All styling via \`className\`. \`\` defaults to \`font-body\` (regular body family), so plain body text needs no family class. - **Family + weight**: \`font-body\` (default, omit for regular), \`font-body-bold\`, \`font-body-extrabold\`; \`font-heading\`, \`font-heading-bold\`, \`font-heading-extrabold\`; \`font-mono\`, \`font-mono-bold\`, \`font-mono-extrabold\` - **Size**: standard Tailwind — \`text-xs\`, \`text-sm\`, \`text-base\`, \`text-lg\`, \`text-xl\`, \`text-2xl\`, \`text-3xl\`, \`text-4xl\`, \`text-5xl\`, \`text-6xl\` - **Color**: \`text-sharp\`, \`text-muted\`, \`text-accent\`, \`text-on-accent\` ~~~tsx Bold body text Extrabold heading Muted monospace ~~~ ### Text vs Paragraph \`\` is \`\` with \`role="paragraph"\` (a real \`

\` on web) and selectable content — use it for prose, one or more sentences. Everything else stays \`\`: a label, a heading, a stat, a URL, a single value, even alone on its line. A value with its own component keeps it (\`Code\`, \`CodeBlock\`, \`ExternalLinkText\`). A \`

\` holds inline children only — never a nested \`Paragraph\`, \`View\` or \`Surface\`. ~~~tsx Run pnpm build before deploying. https://api.example.com/v1 ~~~`, }, }, }, } satisfies Meta; export const PreviewStory: ThisStory = { name: "Text Preview", parameters: { layout: "padded", chromatic: { disableSnapshot: true }, }, args: { children: "The quick brown fox jumps over the lazy dog", }, }; function Sizes() { return ( text-6xl text-5xl text-4xl text-3xl text-2xl text-xl text-lg text-base text-sm text-xs ); } function FamiliesAndWeights() { return ( font-body (default regular) font-body-bold font-body-extrabold font-heading font-heading-bold font-heading-extrabold font-mono font-mono-bold font-mono-extrabold ); } function Colors() { return ( text-sharp — Default text text-muted — Secondary text text-accent — Accented text text-on-accent — Text on accent background ); } function NestedExample() { return ( The future is in{" "} our{" "} hands {" "} to{" "} shape ); } export const VariantsStory: ThisStory = { name: "Text Variants", render: () => ( font-bold would only work on web, so it's overrided. Use font-body-bold instead. ), }; export const Tests: ThisStory = { name: "Text Tests", render: () => ( Paragraph content outer inner ), play: async ({ canvasElement }) => { const canvas = within(canvasElement); const paragraph = canvas.getByText("Paragraph content"); await expect(paragraph).toBeInTheDocument(); await expect(paragraph.tagName).toBe("P"); const inner = getComputedStyle(canvas.getByText("inner")); const outer = getComputedStyle(canvas.getByText(/^outer/)); await expect(inner.fontFamily).toBe(outer.fontFamily); await expect(inner.color).toBe(outer.color); await expect(inner.fontSize).toBe(outer.fontSize); }, };