import type { Meta, StoryObj } from "@storybook/react-vite" import { Avatar, AvatarFallback, AvatarImage } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { STORY_KICKER, 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}
))}
) } function Fallbacks() { const items = [ { label: "한글 두 글자", text: "김한" }, { label: "영문 두 글자", text: "HM" }, { label: "한 글자", text: "한" }, { label: "긴 fallback", text: "ABCDEFGHIJ" }, ] return (
{items.map((i) => (
{i.text} {i.label}
))}
) } function Group() { return (
김한
김한맥 노선 설계팀
) } const sections = [ { id: "image", label: "Image", note: "이미지가 로드되면 fallback은 나타나지 않습니다", node: }, { id: "fallback", label: "Fallback (image error)", note: "이미지 로드 실패 시 initials", 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 const board = (...ids: string[]) => ( ids.includes(s.id)).map((s) => ({ id: s.id, label: s.label, note: s.note, children: s.node }))} /> ) // Representative Story: the common Story page; the sections group the same specimens. export const All: Story = { name: "Avatar", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( {board("image")} {board("fallback")} {board("composition")} ), } export const Image: Story = { tags: ["verification"], render: () => } export const FallbackError: Story = { tags: ["verification"], name: "Fallback", render: () => }