import { useEffect } from 'react'; import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { useRtlDiffI18n, withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator'; import { Snackbar } from '../Snackbar'; import type { SnackbarCreationProps } from '../Snackbar.types'; import SnackbarProvider from '../SnackbarProvider'; import useSnackbar from '../useSnackbar'; export default { component: Snackbar, title: 'Prompts/Snackbar/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; function ShowOnMount(props: SnackbarCreationProps) { const createSnackbar = useSnackbar(); useEffect(() => { createSnackbar(props); // This visual fixture creates once per mount, not on every render of its props. // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return null; } function SnackbarStory({ text, action }: { text: string; action?: { label: string } }) { return ( {text}} action={action} duration="indefinite" /> ); } export const WithAction: Story = { render: () => { const i18n = useRtlDiffI18n(); return ; }, ...withRTLDiff({ renderAs: 'iframe', i18n: { text: { en: 'Transfer completed successfully', ar: 'تم إتمام التحويل بنجاح' }, actionLabel: { en: 'View', ar: 'عرض' }, }, }), }; export const WithoutAction: Story = { render: () => { const i18n = useRtlDiffI18n(); return ; }, ...withRTLDiff({ renderAs: 'iframe', i18n: { text: { en: 'Transfer completed successfully', ar: 'تم إتمام التحويل بنجاح' }, }, }), };