import { expect, fn, within } from "storybook/test"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { ClockRegularIcon } from "alouette-icons/phosphor-icons/Clock"; import { EyeRegularIcon } from "alouette-icons/phosphor-icons/Eye"; import { PressableListItem } from "../actions/PressableListItem"; import { Text } from "../primitives/Text"; import { View } from "../primitives/View"; import { Story } from "../story-components/Story"; import { SectionTitle } from "./SectionTitle"; type ThisStory = StoryObj; export default { title: "alouette/Layout/SectionTitle", component: SectionTitle, parameters: { componentSubtitle: "The heading of a section of the screen, with no material of its own.", docs: { description: { component: `### Composition ~~~tsx } accent="info"> Waiting for your review … ~~~ - A heading (\`role="heading"\`, \`level\` 2 by default — an \`

\` on web) - \`accent\` tints the icon and the title; without one the icon is muted and the title sharp - It stands on the screen ground: a list of \`PressableListItem\` rows is raised on its own, so the section is never wrapped in a \`surface\``, }, }, }, } satisfies Meta; function Rows() { return ( feat: add SectionTitle fix: align the header ); } export const PreviewSectionTitleStory: ThisStory = { name: "SectionTitle Preview", parameters: { chromatic: { disableSnapshot: true } }, args: { children: "Waiting for your review", accent: "info", }, render: (args) => ( } /> ), }; export const VariantsSectionTitleStory: ThisStory = { name: "SectionTitle Variants", render: () => ( Repositories }>In progress } accent="info"> Waiting for your review } accent="info" level={3}> Waiting for your review ), play: async ({ canvasElement }) => { const canvas = within(canvasElement); // Each section renders once per color mode. const plainHeadings = canvas.getAllByRole("heading", { name: "Repositories", level: 2, }); const [plain] = plainHeadings; const [accented] = canvas.getAllByRole("heading", { name: "Waiting for your review", level: 2, }); if (!plain || !accented) throw new Error("expected both headings"); await expect( canvas.getAllByRole("heading", { name: "Waiting for your review", level: 3, }), ).toHaveLength(plainHeadings.length); // The accent tints the title away from the plain sharp ink. await expect(getComputedStyle(accented).color).not.toBe( getComputedStyle(plain).color, ); }, };