({ field, onRemove, variant = "select", isActive = false, style }: FieldCardProps)
| 31 | } |
| 32 | |
| 33 | const FieldCard = ({ field, onRemove, variant = "select", isActive = false, style }: FieldCardProps) => { |
| 34 | const isListVariant = variant === "list"; |
| 35 | const [isHovered, setIsHovered] = useState(false); |
| 36 | const svgPoints = getPolygonPoints(field.coordinates); |
| 37 | const areaAcres = haToAcres(field.area); |
| 38 | |
| 39 | return ( |
| 40 | <div |
| 41 | className="flex items-center gap-3 p-3 rounded-lg border transition-all duration-300 ease-out cursor-pointer group" |
| 42 | style={{ |
| 43 | ...style, |
| 44 | backgroundColor: isActive ? "hsl(150, 15%, 20%)" : isHovered ? "hsl(150, 15%, 18%)" : "hsl(150, 15%, 14%)", |
| 45 | transform: isHovered ? "translateX(-2px) scale(1.01)" : "translateX(0) scale(1)", |
| 46 | boxShadow: isActive |
| 47 | ? `0 0 0 1px ${field.color}88, 0 4px 20px -4px ${field.color}33` |
| 48 | : isHovered ? `0 4px 20px -4px ${field.color}33, inset 0 0 0 1px ${field.color}44` : "none", |
| 49 | borderColor: isActive ? field.color + "88" : isHovered ? field.color + "66" : "hsl(150, 12%, 22%)", |
| 50 | }} |
| 51 | onMouseEnter={() => setIsHovered(true)} |
| 52 | onMouseLeave={() => setIsHovered(false)} |
| 53 | > |
| 54 | <div |
| 55 | className="w-12 h-12 rounded-md flex items-center justify-center flex-shrink-0 overflow-hidden transition-transform duration-300" |
| 56 | style={{ backgroundColor: field.color + "15", transform: isHovered ? "rotate(-5deg) scale(1.1)" : "rotate(0) scale(1)" }} |
| 57 | > |
| 58 | <svg viewBox="0 0 40 40" className="w-8 h-8"> |
| 59 | <polygon points={svgPoints} fill={field.color + "44"} stroke={field.color} strokeWidth="2" /> |
| 60 | </svg> |
| 61 | </div> |
| 62 | <div className="flex-1 min-w-0"> |
| 63 | <div className="flex items-center gap-2"> |
| 64 | <span className="text-sm font-medium text-foreground">{field.name}, {areaAcres} acres</span> |
| 65 | {isListVariant && field.ndviChange !== undefined && ( |
| 66 | <span className="text-xs font-semibold" style={{ color: field.ndviChange >= 0 ? "hsl(120, 50%, 50%)" : "hsl(0, 62%, 50%)" }}> |
| 67 | {field.ndviChange >= 0 ? "+" : ""}{field.ndviChange.toFixed(2)} |
| 68 | </span> |
| 69 | )} |
| 70 | </div> |
| 71 | <div className="text-xs text-muted-foreground">{field.crop}</div> |
| 72 | {isListVariant && field.group && <div className="text-xs text-muted-foreground">{field.group}</div>} |
| 73 | <div className="text-xs text-muted-foreground flex items-center gap-1"> |
| 74 | <MapPin className="w-3 h-3 text-muted-foreground flex-shrink-0" /> {field.location} |
| 75 | </div> |
| 76 | </div> |
| 77 | <button |
| 78 | onClick={(e) => { e.stopPropagation(); onRemove(field.id); }} |
| 79 | className="text-muted-foreground hover:text-foreground transition-all duration-200 flex-shrink-0 opacity-60 group-hover:opacity-100" |
| 80 | style={{ transform: isHovered ? "scale(1.15)" : "scale(1)" }} |
| 81 | > |
| 82 | {isListVariant ? <MoreHorizontal className="w-4 h-4" /> : <X className="w-4 h-4" />} |
| 83 | </button> |
| 84 | </div> |
| 85 | ); |
| 86 | }; |
| 87 | |
| 88 | export default FieldCard; |
nothing calls this directly
no test coverage detected