AgentCard.tsx
1.67 KB
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
import { useState } from 'react';
import type { Agent } from '../types/home';
export interface AgentCardProps {
agent: Agent;
isSelected: boolean;
onClick: () => void;
}
export function AgentCard({ agent, isSelected, onClick }: AgentCardProps) {
const [iconError, setIconError] = useState(false);
const handleIconError = () => {
setIconError(true);
};
return (
<button
onClick={onClick}
className={`w-full p-5 rounded-2xl border transition-all group cursor-default ${
isSelected
? 'border-primary/40 bg-primary/10 shadow-md'
: 'border-outline-variant/30 bg-surface-container-lowest hover:border-primary/40 hover:shadow-md'
}`}
>
<div className="flex items-start gap-4">
<div className={`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 transition-colors ${
isSelected
? 'bg-primary text-white'
: 'bg-primary/10 text-primary group-hover:bg-primary group-hover:text-white'
}`}>
{agent.icon_url && !iconError ? (
<img
src={agent.icon_url}
alt={agent.agent_name}
className="w-6 h-6 object-contain"
onError={handleIconError}
/>
) : (
<span className="text-[20px]">★</span>
)}
</div>
<div className="flex-1 min-w-0 text-left">
<p className="text-label-md font-bold mb-1">
{agent.speech_title ?? agent.agent_name}
</p>
<p className="text-body-md text-on-surface-variant text-sm">
{agent.speech_content ?? ''}
</p>
</div>
</div>
</button>
);
}