All files / src/components/profile SectionCard.tsx

100% Statements 2/2
100% Branches 10/10
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                            875x 875x                                                                
import { Pencil, Plus } from "lucide-react";
import type { ReactNode } from "react";
import { Button } from "../ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
 
interface SectionCardProps {
	title: string;
	icon: ReactNode;
	onEdit?: () => void;
	isEmpty?: boolean;
	className?: string;
	children: ReactNode;
}
 
export function SectionCard({
	title,
	icon,
	onEdit,
	isEmpty,
	className,
	children,
}: SectionCardProps) {
	const cardClass = [isEmpty ? "border-amber-200 bg-amber-50/50" : "", className].filter(Boolean).join(" ") || undefined;
	return (
		<Card className={cardClass}>
			<CardHeader className="flex flex-row items-start sm:items-center justify-between gap-2 space-y-0 pb-4">
				<CardTitle className="flex flex-wrap items-center gap-1.5 sm:gap-2 text-sm sm:text-base min-w-0">
					<span className="flex-shrink-0">{icon}</span>
					<span className="truncate">{title}</span>
					{isEmpty && (
						<span className="text-[10px] sm:text-xs font-medium px-1.5 sm:px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 flex-shrink-0">
							Not filled
						</span>
					)}
				</CardTitle>
				{onEdit && (
					<Button variant="outline" size="sm" onClick={onEdit} className="flex-shrink-0">
						{isEmpty ? (
							<>
								<Plus className="h-3.5 w-3.5 mr-1" />
								Add
							</>
						) : (
							<>
								<Pencil className="h-3.5 w-3.5 mr-1" />
								Edit
							</>
						)}
					</Button>
				)}
			</CardHeader>
			<CardContent>{children}</CardContent>
		</Card>
	);
}