import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { useRef } from 'react'; import { useRtlDiffI18n, withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator'; import Button from '../../../Button'; import { Position } from '../../PropsValues/position'; import Panel from '../Panel'; export default { component: Panel, title: 'Dialogs/Panel/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; function PanelStory({ position, label, }: { position: Parameters[0]['position']; label: string; }) { const i18n = useRtlDiffI18n(); const anchorRef = useRef(null); const margin = position?.startsWith('bottom') || position?.startsWith('top') ? '3.5rem 0' : '2.5rem 0'; return ( <>
{i18n.panelContentPrefix} {label}
); } export const Top: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, topLeft: { en: 'top-left', ar: 'أعلى اليسار' }, top: { en: 'top', ar: 'أعلى' }, topRight: { en: 'top-right', ar: 'أعلى اليمين' }, }, }), }; export const Right: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, rightTop: { en: 'right-top', ar: 'اليمين أعلى' }, right: { en: 'right', ar: 'اليمين' }, rightBottom: { en: 'right-bottom', ar: 'اليمين أسفل' }, }, }), }; export const RightFlipped: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, rightTop: { en: 'right-top', ar: 'اليمين أعلى' }, right: { en: 'right', ar: 'اليمين' }, rightBottom: { en: 'right-bottom', ar: 'اليمين أسفل' }, }, }), }; export const Bottom: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, bottomLeft: { en: 'bottom-left', ar: 'أسفل اليسار' }, bottom: { en: 'bottom', ar: 'أسفل' }, bottomRight: { en: 'bottom-right', ar: 'أسفل اليمين' }, }, }), }; export const Left: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, leftTop: { en: 'left-top', ar: 'اليسار أعلى' }, left: { en: 'left', ar: 'اليسار' }, leftBottom: { en: 'left-bottom', ar: 'اليسار أسفل' }, }, }), }; export const LeftFlipped: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> ); }, ...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center', i18n: { panelAriaLabelPrefix: { en: 'Panel positioned', ar: 'لوحة موضوعة عند' }, panelContentPrefix: { en: 'Panel content positioned at', ar: 'محتوى اللوحة موضوع عند' }, leftTop: { en: 'left-top', ar: 'اليسار أعلى' }, left: { en: 'left', ar: 'اليسار' }, leftBottom: { en: 'left-bottom', ar: 'اليسار أسفل' }, }, }), };