import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { userEvent, within } from 'storybook/test'; import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator'; import Button from '../../Button'; import Tooltip from '../Tooltip'; export default { component: Tooltip, title: 'Dialogs/Tooltip/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; const hoverTrigger = async ({ canvasElement }: { canvasElement: HTMLElement }) => { const canvas = within(canvasElement); const button = canvas.queryByRole('button'); if (!button) return; await userEvent.hover(button); }; export const PositionTop: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: hoverTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom', i18n: { tooltip: { en: 'Top positioned tooltip', ar: 'تلميح في الأعلى' }, trigger: { en: 'Top', ar: 'أعلى' }, }, }), }; export const PositionBottom: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: hoverTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', i18n: { tooltip: { en: 'Bottom positioned tooltip', ar: 'تلميح في الأسفل' }, trigger: { en: 'Bottom', ar: 'أسفل' }, }, }), }; export const PositionRight: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: hoverTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center', i18n: { tooltip: { en: 'Right positioned tooltip', ar: 'تلميح على اليمين' }, trigger: { en: 'Right', ar: 'يمين' }, }, }), }; export const PositionLeft: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: hoverTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center', i18n: { tooltip: { en: 'Left positioned tooltip', ar: 'تلميح على اليسار' }, trigger: { en: 'Left', ar: 'يسار' }, }, }), };