556
Bn
bees-nest / files
bees-nest / src / components / result-card.tsx
2.6 KB
1"use client"; 2 3import { ArrowRight01Icon } from "@hugeicons/core-free-icons"; 4import { HugeiconsIcon } from "@hugeicons/react"; 5import Image from "next/image"; 6import Link from "next/link"; 7import type * as React from "react"; 8 9import { Badge } from "@/components/ui/badge"; 10import { Button } from "@/components/ui/button"; 11import { 12 Card, 13 CardContent, 14 CardDescription, 15 CardFooter, 16 CardHeader, 17 CardTitle, 18} from "@/components/ui/card"; 19import { cn } from "@/lib/utils"; 20 21export interface SearchResult { 22 id: string; 23 title: string; 24 description: string; 25 source: string; 26 url: string; 27 imageUrl?: string; 28 date?: string; 29} 30 31interface ResultCardProps extends React.ComponentProps<typeof Card> { 32 result: SearchResult; 33} 34 35export function ResultCard({ result, className, ...props }: ResultCardProps) { 36 return ( 37 <Link 38 href={result.url} 39 target="_blank" 40 rel="noopener noreferrer" 41 className="block" 42 > 43 <Card 44 className={cn( 45 "overflow-hidden transition-colors hover:bg-muted/40", 46 className, 47 )} 48 {...props} 49 > 50 <div className="flex flex-col sm:flex-row"> 51 {result.imageUrl && ( 52 <div className="relative h-48 w-full sm:h-auto sm:w-48 shrink-0 bg-muted"> 53 <Image 54 src={result.imageUrl} 55 alt={result.title} 56 fill 57 className="object-cover" 58 /> 59 </div> 60 )} 61 <div className="flex flex-1 flex-col"> 62 <CardHeader> 63 <div className="flex items-start justify-between gap-4"> 64 <div className="space-y-1"> 65 <CardTitle className="line-clamp-1">{result.title}</CardTitle> 66 <CardDescription className="line-clamp-2"> 67 {result.description} 68 </CardDescription> 69 </div> 70 <Badge variant="secondary" className="shrink-0"> 71 {result.source} 72 </Badge> 73 </div> 74 </CardHeader> 75 <CardContent className="flex-1"> 76 {/* Additional content could go here */} 77 </CardContent> 78 <CardFooter className="justify-between"> 79 <span className="text-xs text-muted-foreground"> 80 {result.date || "Recently indexed"} 81 </span> 82 <Button variant="ghost" size="sm" className="gap-1 text-xs"> 83 Read more 84 <HugeiconsIcon icon={ArrowRight01Icon} className="size-3" /> 85 </Button> 86 </CardFooter> 87 </div> 88 </div> 89 </Card> 90 </Link> 91 ); 92}