import type { Meta, StoryObj } from "@storybook/react-vite" import { AspectRatio, Card, CardContent } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // AspectRatio is a layout primitive: it keeps the ratio and nothing else. The image styling (object-fit, radius) in these Stories is // the consumer's composition on the child, not part of AspectRatio. Images are inline data URIs (no network). The Card example only // shows how a consumer can compose it; AspectRatio does not depend on Card. const svg = (label: string, fill: string) => "data:image/svg+xml;utf8," + encodeURIComponent( `${label}` ) function Image({ ratio, label }: { ratio: number; label: string }) { return (
{`${label}
) } function Placeholder() { return (
영상 영역 16:9
) } function InCard() { return ( 카드 안 4:3 이미지 ) } const sections = [ { id: "r169", label: "16:9", node: }, { id: "r43", label: "4:3", node: }, { id: "r11", label: "1:1", node: }, { id: "video", label: "Video", node: }, { id: "card", label: "Card", node: }, ] const meta = { title: "Components/Data & Display/Aspect Ratio", component: AspectRatio, 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 // (200px 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. // The Card example spans two columns (about its previous width); the ratio boxes fill their column by design. 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 (16:9) is merged into Variants (16:9, 4:3, 1:1, Video), 4 columns on PC; Card stays under Usage. export const All: Story = { name: "Aspect Ratio", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( ), } export const Wide: Story = { tags: ["verification"], name: "16:9", render: () => } export const Square: Story = { tags: ["verification"], name: "1:1", render: () => }