import VTooltip from './VTooltip.vue'; import VButton from './VButton.vue'; // Example trigger import type { Meta, StoryObj } from '@storybook/vue3'; const meta: Meta = { title: 'Valerie/VTooltip', component: VTooltip, tags: ['autodocs'], argTypes: { text: { control: 'text', description: 'Tooltip text content.' }, position: { control: 'select', options: ['top', 'bottom', 'left', 'right'], description: 'Tooltip position relative to the trigger.', }, id: { control: 'text', description: 'Optional ID for the tooltip text element (ARIA).' }, // Slot default: { description: 'The trigger element for the tooltip.', table: { disable: true } }, }, parameters: { docs: { description: { component: 'A tooltip component that displays informational text when a trigger element is hovered or focused. Uses CSS for positioning and visibility.', }, }, // Adding some layout to center stories and provide space for tooltips layout: 'centered', }, // Decorator to add some margin around stories so tooltips don't get cut off by viewport decorators: [() => ({ template: '
' })], }; export default meta; type Story = StoryObj; export const Top: Story = { render: (args) => ({ components: { VTooltip, VButton }, setup() { return { args }; }, template: ` Hover or Focus Me (Top) `, }), args: { text: 'This is a tooltip displayed on top.', position: 'top', id: 'tooltip-top-example', }, }; export const Bottom: Story = { ...Top, // Reuses render function from Top story args: { text: 'Tooltip shown at the bottom.', position: 'bottom', id: 'tooltip-bottom-example', }, }; export const Left: Story = { ...Top, args: { text: 'This appears to the left.', position: 'left', id: 'tooltip-left-example', }, }; export const Right: Story = { ...Top, args: { text: 'And this one to the right!', position: 'right', id: 'tooltip-right-example', }, }; export const OnPlainText: Story = { render: (args) => ({ components: { VTooltip }, setup() { return { args }; }, template: `

Some text here, and this part has a tooltip which shows up on hover or focus.

`, }), args: { text: 'Tooltip on a span of text!', position: 'top', }, }; export const LongTextTooltip: Story = { ...Top, args: { text: 'This is a much longer tooltip text to see how it behaves. It should remain on a single line by default due to white-space: nowrap. If multi-line is needed, CSS for .tooltip-text would need adjustment (e.g., white-space: normal, width/max-width).', position: 'bottom', }, parameters: { docs: { description: { story: 'Demonstrates a tooltip with a longer text content. Default styling keeps it on one line.'} } } }; export const WithSpecificId: Story = { ...Top, args: { text: 'This tooltip has a specific ID for its text element.', position: 'top', id: 'my-custom-tooltip-id-123', }, };