'use client'; import { Image as ImageIcon, Code, FileQuestion, ChevronRight } from 'lucide-react'; import { clsx } from 'clsx'; import { TASK_LABELS, CATEGORY_LABELS } from '@/config/constants'; import { previewText } from '@/lib/utils/response'; import { ExpandableImage } from '../ui/ImageLightbox'; import type { DatasetExample } from '@/types'; interface ExampleCardProps { example: DatasetExample; onSelect: (example: DatasetExample) => void; isSelected?: boolean; } export function ExampleCard({ example, onSelect, isSelected }: ExampleCardProps) { const taskConfig = TASK_LABELS[example.type]; const categoryConfig = CATEGORY_LABELS[example.category]; const getTaskIcon = () => { switch (example.type) { case 'function_completion': return ; case 'code_generation': return ; case 'qa': return ; } }; // Muted badge colors const badgeColors: Record = { function_completion: 'bg-emerald-900/30 text-emerald-400 border-emerald-700/30', code_generation: 'bg-blue-900/30 text-blue-400 border-blue-700/30', qa: 'bg-amber-900/30 text-amber-400 border-amber-700/30', }; const selectExample = () => onSelect(example); return ( { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); selectExample(); } }} className={clsx( 'w-full text-left p-3 rounded-lg transition-all duration-200 group cursor-pointer', 'border hover:border-teal-700/40', isSelected ? 'bg-teal-900/20 border-teal-700/40' : 'bg-zinc-800/50 border-zinc-700/30 hover:bg-zinc-800/80' )} > {example.hasImage && ( e.stopPropagation()}> {example.imageUrl ? ( ) : ( )} )} {getTaskIcon()} {taskConfig.label} {categoryConfig} {previewText(example.question, 120)} ); }
{previewText(example.question, 120)}