import type { Meta, StoryObj } from "@storybook/react-vite" import { Avatar, AvatarFallback, AvatarImage } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // Images are inline data URIs so the Story does not depend on the network. "Broken" uses an address that cannot load so the // Radix fallback shows. Radix renders the image only after it loads. const photo = "data:image/svg+xml;utf8," + encodeURIComponent( '' ) function Sizes() { return (
{(["sm", "default", "lg"] as const).map((size) => (
한맥 {size}
))}
) } // `showCaption={false}` drops the captions on the representative page (they restate the visible fallback text); the verification Story keeps them. function Fallbacks({ showCaption = true }: { showCaption?: boolean }) { const items = [ { label: "한글 두 글자", text: "김한" }, { label: "영문 두 글자", text: "HM" }, { label: "한 글자", text: "한" }, { label: "긴 fallback", text: "ABCDEFGHIJ" }, ] return (
{items.map((i) => (
{i.text} {showCaption ? {i.label} : null}
))}
) } function Group() { return (
김한
김한맥 노선 설계팀
) } const sections = [ { id: "image", label: "Image", node: }, { id: "fallback", label: "Fallback", node: }, { id: "composition", label: "Composition", node: }, ] const meta = { title: "Components/Data & Display/Avatar", component: Avatar, parameters: { layout: "padded" } } satisfies Meta export default meta type Story = StoryObj // Representative-page layout (Storybook presentation only): equal columns on PC (iframe width 1000px and up), fewer below that // (240px minimum). Each specimen sits in its own single-column StateBoard (min larger than any column), so every subtitle and divider // has the width of its column; a section with fewer specimens than columns leaves the remaining columns empty. const specimenColumns = { 2: "min-[1000px]:grid-cols-2", 3: "min-[1000px]:grid-cols-3", 4: "min-[1000px]:grid-cols-4", } as const function SpecimenGrid({ ids, columns, spans = {} }: { ids: string[]; columns: 2 | 3 | 4; spans?: Record }) { return (
{ids.map((id) => { const s = sections.find((section) => section.id === id)! return (
) })}
) } // Representative Story: the common Story page; the sections group the same specimens. // Representative Story: Overview / States are merged into Variants (Image, Fallback); Composition stays under Usage. 3 columns on PC. export const All: Story = { name: "Avatar", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( ), } export const Image: Story = { tags: ["verification"], render: () => } export const FallbackError: Story = { tags: ["verification"], name: "Fallback", render: () => }