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 { Position } from '../../common'; import Popover from '..'; export default { component: Popover, title: 'Dialogs/Popover/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; const clickTrigger = async ({ canvasElement }: { canvasElement: HTMLElement }) => { const canvas = within(canvasElement); const trigger = canvas.queryByRole('button'); if (!trigger) return; await userEvent.click(trigger); }; export const PlacementRight: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: clickTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center', i18n: { title: { en: 'Guaranteed rate', ar: 'سعر مضمون' }, content: { en: "You'll get this rate as long as we receive your 10 EUR within the next 51 hours.", ar: 'ستحصل على هذا السعر إذا استلمنا مبلغ 10 يورو خلال 51 ساعة القادمة.', }, trigger: { en: 'right', ar: 'اليمين' }, }, }), }; export const PlacementLeft: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: clickTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center', i18n: { title: { en: 'Guaranteed rate', ar: 'سعر مضمون' }, content: { en: "You'll get this rate as long as we receive your 10 EUR within the next 51 hours.", ar: 'ستحصل على هذا السعر إذا استلمنا مبلغ 10 يورو خلال 51 ساعة القادمة.', }, trigger: { en: 'left', ar: 'اليسار' }, }, }), }; export const PlacementTop: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: clickTrigger, ...withRTLDiff({ renderAs: 'iframe', vAlign: 'bottom', hAlign: 'center', i18n: { title: { en: 'Guaranteed rate', ar: 'سعر مضمون' }, content: { en: "You'll get this rate as long as we receive your 10 EUR within the next 51 hours.", ar: 'ستحصل على هذا السعر إذا استلمنا مبلغ 10 يورو خلال 51 ساعة القادمة.', }, trigger: { en: 'top', ar: 'أعلى' }, }, }), }; export const PlacementBottom: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: clickTrigger, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', i18n: { title: { en: 'Guaranteed rate', ar: 'سعر مضمون' }, content: { en: "You'll get this rate as long as we receive your 10 EUR within the next 51 hours.", ar: 'ستحصل على هذا السعر إذا استلمنا مبلغ 10 يورو خلال 51 ساعة القادمة.', }, trigger: { en: 'bottom', ar: 'أسفل' }, }, }), };