import React from 'react'; import Box from '@mui/material/Box'; import type { SxProps, Theme } from '@mui/material/styles'; import { Typography } from '../../atoms/Typography'; import { Badge } from '../../atoms/Badge'; import { Card } from '../../atoms/Card'; import type { ComparisonPackage } from '../../organisms/ComparisonTable'; // ─── Types ─────────────────────────────────────────────────────────────────── export interface ComparisonTabCardProps { /** Package data to render */ pkg: ComparisonPackage; /** Whether this tab is the currently active/selected one */ isActive: boolean; /** Whether any package in the rail is recommended — controls spacer for alignment */ hasRecommended: boolean; /** ARIA: id for the tab element */ tabId: string; /** ARIA: id of the controlled tabpanel */ tabPanelId: string; /** Called when the tab card is clicked */ onClick: () => void; /** MUI sx prop for outer wrapper */ sx?: SxProps; } // ─── Helpers ──────────────────────────────────────────────────────────────── function formatPrice(amount: number): string { return `$${amount.toLocaleString('en-AU', { minimumFractionDigits: amount % 1 !== 0 ? 2 : 0 })}`; } // ─── Component ────────────────────────────────────────────────────────────── /** * Mini tab card for the mobile ComparisonPage tab rail. * * Shows provider name, package name, and price. Recommended packages get a * floating badge (in normal flow with negative margin overlap) and a warm * brand glow. Non-recommended cards get a spacer to keep vertical alignment * when a recommended card is present in the rail. * * The page component owns scroll/centering behaviour — this is purely visual. */ export const ComparisonTabCard = React.forwardRef( ({ pkg, isActive, hasRecommended, tabId, tabPanelId, onClick, sx }, ref) => { return ( {/* Recommended badge in normal flow — overlaps card via negative mb */} {pkg.isRecommended ? ( Recommended ) : ( // Spacer keeps cards aligned when a recommended card is present hasRecommended && )} {pkg.provider.name} {pkg.name} {formatPrice(pkg.price)} ); }, ); ComparisonTabCard.displayName = 'ComparisonTabCard'; export default ComparisonTabCard;