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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 8x 21x 21x 1x | import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
interface Template {
id: string;
name: string;
description: string | null;
}
interface TemplateGalleryProps {
templates: Template[];
selectedTemplate: string;
onSelect: (templateId: string) => void;
}
export function TemplateGallery({
templates,
selectedTemplate,
onSelect,
}: TemplateGalleryProps) {
return (
<Card>
<CardHeader>
<CardTitle>Choose Your Template</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{templates.map((template) => {
const isSelected = selectedTemplate === template.id;
return (
<button
key={template.id}
type="button"
onClick={() => onSelect(template.id)}
className={`relative p-6 rounded-xl border-2 text-left transition-all ${
isSelected
? "border-primary-500 ring-2 ring-primary-200"
: "border-border-default hover:border-border-strong"
}`}
>
<div className="h-32 rounded-lg mb-4 overflow-hidden">
<img
src={`/templates/${template.id}-preview.webp`}
alt={`${template.name} template preview`}
className="w-full h-full object-cover object-top"
loading="lazy"
/>
</div>
<h3 className="font-semibold text-foreground-default">
{template.name}
</h3>
<p className="text-sm text-foreground-muted mt-1">
{template.description}
</p>
{isSelected && (
<div className="absolute top-4 right-4 w-6 h-6 bg-primary-500 rounded-full flex items-center justify-center">
<svg
className="w-4 h-4 text-foreground-inverse"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
role="img"
aria-label="Selected"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M5 13l4 4L19 7"
/>
</svg>
</div>
)}
</button>
);
})}
</div>
</CardContent>
</Card>
);
}
|