|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import type { DemoItem } from "./demo-data"; |
| 4 | + |
| 5 | +// Category badge colors |
| 6 | +const CATEGORY_COLORS: Record<string, { bg: string; text: string }> = { |
| 7 | + "3D / Animation": { bg: "rgba(139,92,246,0.12)", text: "rgba(139,92,246,1)" }, |
| 8 | + "Data Visualization": { bg: "rgba(59,130,246,0.12)", text: "rgba(59,130,246,1)" }, |
| 9 | + Diagrams: { bg: "rgba(16,185,129,0.12)", text: "rgba(16,185,129,1)" }, |
| 10 | + Interactive: { bg: "rgba(245,158,11,0.12)", text: "rgba(245,158,11,1)" }, |
| 11 | + "UI Components": { bg: "rgba(236,72,153,0.12)", text: "rgba(236,72,153,1)" }, |
| 12 | +}; |
| 13 | + |
| 14 | +// Emoji background gradients |
| 15 | +const EMOJI_GRADIENTS: Record<string, string> = { |
| 16 | + "3D / Animation": |
| 17 | + "linear-gradient(135deg, rgba(139,92,246,0.08) 0%, rgba(59,130,246,0.06) 100%)", |
| 18 | + "Data Visualization": |
| 19 | + "linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(16,185,129,0.06) 100%)", |
| 20 | + Diagrams: |
| 21 | + "linear-gradient(135deg, rgba(16,185,129,0.08) 0%, rgba(59,130,246,0.06) 100%)", |
| 22 | + Interactive: |
| 23 | + "linear-gradient(135deg, rgba(245,158,11,0.08) 0%, rgba(236,72,153,0.06) 100%)", |
| 24 | + "UI Components": |
| 25 | + "linear-gradient(135deg, rgba(236,72,153,0.08) 0%, rgba(139,92,246,0.06) 100%)", |
| 26 | +}; |
| 27 | + |
| 28 | +interface DemoCardProps { |
| 29 | + demo: DemoItem; |
| 30 | + onTry: (demo: DemoItem) => void; |
| 31 | +} |
| 32 | + |
| 33 | +export function DemoCard({ demo, onTry }: DemoCardProps) { |
| 34 | + const categoryColor = CATEGORY_COLORS[demo.category] ?? { |
| 35 | + bg: "rgba(100,100,100,0.12)", |
| 36 | + text: "rgba(100,100,100,1)", |
| 37 | + }; |
| 38 | + |
| 39 | + return ( |
| 40 | + <div |
| 41 | + className="rounded-xl overflow-hidden flex flex-col transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5" |
| 42 | + style={{ |
| 43 | + border: "1px solid var(--color-border-glass, rgba(0,0,0,0.1))", |
| 44 | + background: "var(--surface-primary, #fff)", |
| 45 | + }} |
| 46 | + > |
| 47 | + {/* Preview area */} |
| 48 | + <div |
| 49 | + className="relative overflow-hidden" |
| 50 | + style={{ |
| 51 | + height: 160, |
| 52 | + background: |
| 53 | + EMOJI_GRADIENTS[demo.category] ?? |
| 54 | + "var(--color-background-secondary)", |
| 55 | + }} |
| 56 | + > |
| 57 | + <div className="flex items-center justify-center h-full"> |
| 58 | + <span className="text-5xl" role="img" aria-label={demo.title}> |
| 59 | + {demo.emoji} |
| 60 | + </span> |
| 61 | + </div> |
| 62 | + |
| 63 | + {/* Category badge */} |
| 64 | + <span |
| 65 | + className="absolute top-2 right-2 text-[10px] font-semibold px-2 py-0.5 rounded-full" |
| 66 | + style={{ |
| 67 | + background: categoryColor.bg, |
| 68 | + color: categoryColor.text, |
| 69 | + }} |
| 70 | + > |
| 71 | + {demo.category} |
| 72 | + </span> |
| 73 | + </div> |
| 74 | + |
| 75 | + {/* Info */} |
| 76 | + <div className="flex flex-col gap-1 p-3 flex-1"> |
| 77 | + <div className="flex items-center gap-2"> |
| 78 | + <span className="text-base">{demo.emoji}</span> |
| 79 | + <h3 |
| 80 | + className="text-sm font-semibold truncate" |
| 81 | + style={{ color: "var(--text-primary, #1a1a1a)" }} |
| 82 | + > |
| 83 | + {demo.title} |
| 84 | + </h3> |
| 85 | + </div> |
| 86 | + <p |
| 87 | + className="text-xs line-clamp-2" |
| 88 | + style={{ color: "var(--text-secondary, #666)" }} |
| 89 | + > |
| 90 | + {demo.description} |
| 91 | + </p> |
| 92 | + </div> |
| 93 | + |
| 94 | + {/* Action */} |
| 95 | + <div className="p-3 pt-0"> |
| 96 | + <button |
| 97 | + onClick={() => onTry(demo)} |
| 98 | + className="w-full text-xs font-medium py-2 rounded-lg transition-all duration-150 hover:scale-[1.02] text-white cursor-pointer" |
| 99 | + style={{ |
| 100 | + background: |
| 101 | + "linear-gradient(135deg, var(--color-lilac-dark, #6366f1), var(--color-mint-dark, #10b981))", |
| 102 | + }} |
| 103 | + > |
| 104 | + Try it |
| 105 | + </button> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + ); |
| 109 | +} |
0 commit comments