import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { userEvent, within } from 'storybook/test'; import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator'; import Info from '..'; export default { component: Info, title: 'Dialogs/Info/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; const openInfo = async ({ canvasElement }: { canvasElement: HTMLElement }) => { const canvas = within(canvasElement); const button = canvas.queryByRole('button'); if (!button) return; await userEvent.click(button); }; export const PlacementTop: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: openInfo, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom', i18n: { trigger: { en: 'Info trigger', ar: 'زر المعلومات' }, title: { en: 'Information', ar: 'معلومات' }, content: { en: 'This is some descriptive content inside the info component.', ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.', }, }, }), }; export const PlacementRight: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: openInfo, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center', i18n: { trigger: { en: 'Info trigger', ar: 'زر المعلومات' }, title: { en: 'Information', ar: 'معلومات' }, content: { en: 'This is some descriptive content inside the info component.', ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.', }, }, }), }; export const PlacementBottom: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: openInfo, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', i18n: { trigger: { en: 'Info trigger', ar: 'زر المعلومات' }, title: { en: 'Information', ar: 'معلومات' }, content: { en: 'This is some descriptive content inside the info component.', ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.', }, }, }), }; export const PlacementLeft: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: openInfo, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center', i18n: { trigger: { en: 'Info trigger', ar: 'زر المعلومات' }, title: { en: 'Information', ar: 'معلومات' }, content: { en: 'This is some descriptive content inside the info component.', ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.', }, }, }), }; export const Modal: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( ); }, play: openInfo, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'center', i18n: { trigger: { en: 'Info trigger', ar: 'زر المعلومات' }, title: { en: 'Information', ar: 'معلومات' }, content: { en: 'This is some descriptive content inside the info component.', ar: 'هذا محتوى وصفي داخل مكوّن المعلومات.', }, }, }), };