import type { Meta, StoryObj } from "@storybook/react-vite" import { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@hm-design/ui" import { StateBoard, type BoardState } from "@/components/story-board" import { StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // Tooltip is a Radix overlay (Portal) with short, non-interactive text. The representative Story shows real triggers // (hover or focus to open); the verification Story starts one open. Interactive content belongs in Popover / Hover Card. const longText = "긴 설명은 최대 폭에서 줄바꿈됩니다. 이 정도 길이가 Tooltip의 한계이며, 더 긴 내용은 Popover나 Hover Card를 사용합니다." function Basic({ defaultOpen }: { defaultOpen?: boolean }) { return ( 저장하지 않은 변경 사항이 있습니다 ) } function Placement({ side }: { side: "top" | "right" | "bottom" | "left" }) { return ( {`side="${side}"`} ) } function LongText() { return ( {longText} ) } function Disabled() { // A disabled button gets no pointer events, so the trigger is a wrapper element. return ( 권한이 없어 사용할 수 없습니다 ) } const meta = { title: "Components/Overlay/Tooltip", component: Tooltip, parameters: { layout: "centered" } } 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 trigger keeps its // own size (the wrapper div stretches, the inline-flex trigger does not). Overlays open in a portal, so this layout never affects them. function SpecimenGrid({ states, columns = 4 }: { states: BoardState[]; columns?: 4 | 5 }) { return (
{states.map((state) => ( {state.children}
}]} /> ))} ) } // Representative Story: Overview is merged into Variants (Basic is its first item, then the four sides): 5 columns on PC. export const All: Story = { name: "Tooltip", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( }, { id: "top", label: "Top", children: }, { id: "right", label: "Right", children: }, { id: "bottom", label: "Bottom", children: }, { id: "left", label: "Left", children: }, ]} /> }, { id: "disabled", label: "Disabled", children: }, ]} /> ), } export const Open: Story = { tags: ["verification"], parameters: { layout: "fullscreen" }, render: () => (
), }