import { ComponentProps, ReactElement, useRef } from 'react'; import { SEMA_SPACE_800, SEMA_SPACE_1200, } from '@swipebox/morphe-design-tokens/dist/js/vr-theme/constants.es'; import DismissButton from './DismissButton'; import Footer from './Footer'; import HeaderSection from './HeaderSection'; import useIsWrappedContainer from './useIsWrappedContainer'; import Box from '../Box'; import Button from '../Button'; import ButtonLink from '../ButtonLink'; import Flex from '../Flex'; import MESSAGING_TYPE_ATTRIBUTES from '../MESSAGING_TYPE_ATTRIBUTES'; type Props = { dismissButton?: { accessibilityLabel?: string; onDismiss: () => void; }; iconAccessibilityLabel?: string; message: string | ReactElement; primaryAction?: | { role: 'link'; accessibilityLabel: string; disabled?: boolean; href: string; label: string; onClick?: ComponentProps['onClick']; rel?: 'none' | 'nofollow'; target?: null | 'self' | 'blank'; } | { role?: 'button'; accessibilityLabel: string; disabled?: boolean; label: string; onClick?: ComponentProps['onClick']; }; secondaryAction?: | { role: 'link'; accessibilityLabel: string; disabled?: boolean; href: string; label: string; onClick?: ComponentProps['onClick']; rel?: 'none' | 'nofollow'; target?: null | 'self' | 'blank'; } | { role?: 'button'; accessibilityLabel: string; disabled?: boolean; label: string; onClick?: ComponentProps['onClick']; }; type: 'default' | 'error' | 'info' | 'recommendation' | 'success' | 'warning'; title?: string; }; export default function BannerCallout({ dismissButton, iconAccessibilityLabel, message, primaryAction, secondaryAction, type, title, }: Props) { const isRtl = typeof document === 'undefined' ? false : document?.dir === 'rtl'; const largePadding = isRtl ? { paddingRight: SEMA_SPACE_800, paddingLeft: SEMA_SPACE_1200 } : { paddingRight: SEMA_SPACE_1200, paddingLeft: SEMA_SPACE_800 }; const backgroundColor = MESSAGING_TYPE_ATTRIBUTES[type]?.backgroundColor; const wrappedRef = useRef(null); const isWrapped = useIsWrappedContainer(wrappedRef, true); return ( {/* SM BREAKPOINT */} {(primaryAction || secondaryAction) && (