import type { Meta, StoryFn } from '@storybook/react'; import { useState } from 'react'; import { Button } from '../button'; import { RadioGroup } from '../radio'; import type { TooltipProps } from './index'; import Tooltip from './index'; export default { title: 'UI/Tooltip', component: Tooltip, } satisfies Meta; const Template: StoryFn = args => ( ); export const Default: StoryFn = Template.bind(undefined); Default.args = {}; export const WithShortCut = () => { const shortCuts = [ ['Text', 'T'], ['Bold', ['⌘', 'B']], ['Quick Search', ['⌘', 'K']], ['Share', ['⌘', 'Shift', 'S']], ['Copy', ['$mod', '$shift', 'C']], ] as Array<[string, string | string[]]>; return (
{shortCuts.map(([name, shortcut]) => ( ))}
); }; export const CustomAlign = () => { const [align, setAlign] = useState('center' as const); const _ = undefined; const positions = [ // [top, left, right, bottom, translateX, translateY] [0, 0, _, _, _, _], [0, '50%', _, _, '-50%', _], [0, _, 0, _, _, _], ['50%', 0, _, _, _, '-50%'], ['50%', _, 0, _, _, '-50%'], [_, 0, _, 0, _, _], [_, '50%', _, 0, '-50%', _], [_, _, 0, 0, _, _], ]; return (
{positions.map(pos => { const key = pos.join('-'); const style = { position: 'absolute', top: pos[0], left: pos[1], right: pos[2], bottom: pos[3], transform: `translate(${pos[4] ?? 0}, ${pos[5] ?? 0})`, } as const; return ( ); })}
); }; export const WithCustomContent: StoryFn = args => (
  • This is a tooltip
  • With custom content
  • } {...args} >
    );