import { clsx } from 'clsx'; import { useIntl } from 'react-intl'; import { Breakpoint, Layout } from '../common'; import { CloseButton } from '../common/closeButton'; import FlowHeader from '../common/flowHeader/FlowHeader'; import Logo from '../logo'; import Stepper, { type Step } from '../stepper/Stepper'; import { useScreenSize } from '../common/hooks/useScreenSize'; import messages from './FlowNavigation.messages'; import AnimatedLabel from './animatedLabel'; import IconButton from '../iconButton'; import { ArrowLeft } from '@transferwise/icons'; export interface FlowNavigationProps { /** @default 0 */ activeStep?: number; avatar?: React.ReactNode; /** @default */ logo?: React.ReactNode; /** @default false */ done?: boolean; /** Called when the close button is clicked. If not provided the close button won't show */ onClose?: () => void; /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */ onGoBack?: () => void; /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */ steps: readonly Step[]; } const FlowNavigation = ({ activeStep = 0, avatar, logo = , done = false, onClose, onGoBack, steps, }: FlowNavigationProps) => { const intl = useIntl(); const closeButton = onClose != null && ; const screenSm = useScreenSize(Breakpoint.SMALL); const screenLg = useScreenSize(Breakpoint.LARGE); const newAvatar = done ? null : avatar; const displayGoBack = onGoBack != null && activeStep > 0; return (
{!screenSm && displayGoBack ? ( ) : (
{logo}
)} {!screenSm && !done && ( )} } rightContent={
{newAvatar} {newAvatar && closeButton && } {closeButton}
} bottomContent={ !done && (steps.length > 0 ? ( ) : (
)) } layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL} />
); }; export default FlowNavigation;