import type { Meta, StoryObj } from "@storybook/react-vite"; import type { ReactNode } from "react"; import { type SafeAreaEdge, SafeAreaScope, } from "../../core/SafeAreaEdgesContext"; import { Box } from "../containers/Box"; import { Text } from "../primitives/Text"; import { View } from "../primitives/View"; import { Story } from "../story-components/Story"; import { ScreenSectionList } from "./ScreenSectionList"; export default { title: "alouette/Layout/ScreenSectionList", component: ScreenSectionList, parameters: { componentSubtitle: "A screen-filling SectionList: bg-screen frame, growing content, safe-area insets as content padding", docs: { description: { component: `### Features - \`bg-screen min-h-full\` frame and a \`grow\` content container, both extendable through \`className\` / \`contentContainerClassName\` (merged with tailwind-merge) - Safe-area insets applied to the **content**, so rows scroll under the system bars but the first and last one clear them - Edges default to everything an ancestor \`SafeAreaScope\` has not declared consumed; \`edges\` overrides them per screen - Insets are native-only: \`useSafeAreaInsets\` is stubbed to zeros on web ### Usage ~~~tsx sections={sections} contentContainerClassName="p-m gap-xxs" keyExtractor={(item) => item.name} renderSectionHeader={({ section }) => } renderItem={({ item }) => } /> ~~~`, }, }, }, } satisfies Meta; interface Contact { name: string; } interface ContactSection { title: string; data: Contact[]; } function ContactRow({ name }: Contact): ReactNode { return ( {name} ); } interface SectionHeaderProps { title: string; } function SectionHeader({ title }: SectionHeaderProps): ReactNode { return ( {title} ); } interface ContactScreenSectionListProps { edges?: readonly SafeAreaEdge[]; } function ContactScreenSectionList({ edges, }: ContactScreenSectionListProps): ReactNode { return ( sections={[ { title: "A", data: [{ name: "Aaron" }, { name: "Alice" }, { name: "Avery" }], }, { title: "B", data: [{ name: "Bianca" }, { name: "Bruno" }] }, { title: "C", data: [{ name: "Cara" }, { name: "Colette" }, { name: "Cyrus" }], }, ]} edges={edges} contentContainerClassName="p-m gap-xxs" keyExtractor={(item) => item.name} renderSectionHeader={({ section }) => ( )} renderItem={({ item }) => } /> ); } export const PreviewStory: StoryObj = { name: "ScreenSectionList Preview", parameters: { chromatic: { disableSnapshot: true } }, render: () => , }; export const VariantsStory: StoryObj = { name: "ScreenSectionList", render: () => ( ), };