Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

example-GuitarRecommendation.tsx

42 lines1.4 KB

1import { useNavigate } from '@tanstack/solid-router'
2​
3import guitars from '../data/example-guitars'
4​
5export default function GuitarRecommendation({ id }: { id: string }) {
6 const navigate = useNavigate()
7 const guitar = guitars.find((guitar) => guitar.id === +id)
8 if (!guitar) {
9 return null
10 }
11 return (
12 <div class="my-4 rounded-lg overflow-hidden border border-orange-500/20 bg-gray-800/50">
13 <div class="aspect-4/3 relative overflow-hidden">
14 <img
15 src={guitar.image}
16 alt={guitar.name}
17 class="w-full h-full object-cover"
18 />
19 </div>
20 <div class="p-4">
21 <h3 class="text-lg font-semibold text-white mb-2">{guitar.name}</h3>
22 <p class="text-sm text-gray-300 mb-3 line-clamp-2">
23 {guitar.shortDescription}
24 </p>
25 <div class="flex items-center justify-between">
26 <div class="text-lg font-bold text-emerald-400">${guitar.price}</div>
27 <button
28 onClick={() => {
29 navigate({
30 to: '/example/guitars/$guitarId',
31 params: { guitarId: guitar.id.toString() },
32 })
33 }}
34 class="bg-linear-to-r from-orange-500 to-red-600 text-white px-4 py-1.5 rounded-lg text-sm hover:opacity-90 transition-opacity"
35 >
36 View Details
37 </button>
38 </div>
39 </div>
40 </div>
41 )