import React from 'react'; import Paper from '@mui/material/Paper'; import Slide from '@mui/material/Slide'; import CompareArrowsIcon from '@mui/icons-material/CompareArrows'; import type { SxProps, Theme } from '@mui/material/styles'; import { Typography } from '../../atoms/Typography'; import { Button } from '../../atoms/Button'; import { Badge } from '../../atoms/Badge'; // ─── Types ─────────────────────────────────────────────────────────────────── /** A package in the comparison basket */ export interface CompareBarPackage { /** Unique package ID */ id: string; /** Package display name */ name: string; /** Provider name */ providerName: string; } /** Props for the CompareBar molecule */ export interface CompareBarProps { /** Packages currently in the comparison basket (max 3 user-selected) */ packages: CompareBarPackage[]; /** Called when user clicks "Compare" CTA */ onCompare: () => void; /** Error/status message shown inline (e.g. "Maximum 3 packages") */ error?: string; /** MUI sx prop for the root wrapper */ sx?: SxProps; } // ─── Component ─────────────────────────────────────────────────────────────── /** * Floating comparison basket pill for the FA design system. * * Shows a fraction badge (1/3, 2/3, 3/3), contextual copy, and a Compare CTA. * Present on both ProvidersStep and PackagesStep. * * Composes Badge + Button + Typography. */ export const CompareBar = React.forwardRef( ({ packages, onCompare, error, sx }, ref) => { const count = packages.length; const visible = count > 0; const canCompare = count >= 2; const statusText = count === 1 ? 'Add another to compare' : 'Ready to compare'; return ( ({ position: 'fixed', bottom: theme.spacing(3), left: '50%', transform: 'translateX(-50%)', zIndex: theme.zIndex.snackbar, borderRadius: '9999px', display: 'flex', alignItems: 'center', gap: 1.5, px: 2.5, py: 1.25, maxWidth: { xs: 'calc(100vw - 32px)', md: 420 }, }), ...(Array.isArray(sx) ? sx : [sx]), ]} > {/* Fraction badge — 1/3, 2/3, 3/3 */} {count}/3 {/* Status text */} {error || statusText} {/* Compare CTA */} ); }, ); CompareBar.displayName = 'CompareBar'; export default CompareBar;