mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 06:51:12 -05:00
Refactor cards to navigate
This commit is contained in:
@@ -108,115 +108,121 @@ export function ContentTabs() {
|
||||
).join(' ');
|
||||
};
|
||||
|
||||
const RideCard = ({ ride }: { ride: Ride }) => (
|
||||
<Card
|
||||
className="group overflow-hidden border-border/50 bg-gradient-to-br from-card via-card to-card/80 hover:shadow-2xl hover:shadow-primary/20 transition-all duration-300 cursor-pointer hover:scale-[1.02]"
|
||||
onClick={() => navigate(`/parks/${ride.park?.slug}/rides/${ride.slug}`)}
|
||||
>
|
||||
<div className="relative overflow-hidden">
|
||||
{/* Image/Icon Section */}
|
||||
<div className="aspect-video bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 flex items-center justify-center relative">
|
||||
{ride.image_url ? (
|
||||
<img
|
||||
src={ride.image_url}
|
||||
alt={ride.name}
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
|
||||
/>
|
||||
) : (
|
||||
<div className="opacity-50 flex items-center justify-center">
|
||||
{getRideIcon(ride.category)}
|
||||
const RideCard = ({ ride }: { ride: Ride }) => {
|
||||
const handleRideClick = () => {
|
||||
navigate(`/parks/${ride.park?.slug}/rides/${ride.slug}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="group overflow-hidden border-border/50 bg-gradient-to-br from-card via-card to-card/80 hover:shadow-2xl hover:shadow-primary/20 transition-all duration-300 cursor-pointer hover:scale-[1.02]"
|
||||
onClick={handleRideClick}
|
||||
>
|
||||
<div className="relative overflow-hidden">
|
||||
{/* Image/Icon Section */}
|
||||
<div className="aspect-video bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 flex items-center justify-center relative">
|
||||
{ride.image_url ? (
|
||||
<img
|
||||
src={ride.image_url}
|
||||
alt={ride.name}
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
|
||||
/>
|
||||
) : (
|
||||
<div className="opacity-50 flex items-center justify-center">
|
||||
{getRideIcon(ride.category)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Gradient Overlay */}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent" />
|
||||
|
||||
{/* Status Badge */}
|
||||
<Badge
|
||||
className={`absolute top-3 right-3 ${getStatusColor(ride.status)} border`}
|
||||
>
|
||||
{ride.status.replace('_', ' ').toUpperCase()}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
<CardContent className="p-4 space-y-3">
|
||||
{/* Header */}
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="font-bold text-lg group-hover:text-primary transition-colors line-clamp-1">
|
||||
{ride.name}
|
||||
</h3>
|
||||
<span className="flex items-center">{getRideIcon(ride.category)}</span>
|
||||
</div>
|
||||
|
||||
{ride.park?.name && (
|
||||
<div className="flex items-center text-sm text-muted-foreground">
|
||||
<MapPin className="w-3 h-3 mr-1" />
|
||||
{ride.park.name}
|
||||
{ride.park.location?.city && `, ${ride.park.location.city}`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Gradient Overlay */}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent" />
|
||||
|
||||
{/* Status Badge */}
|
||||
<Badge
|
||||
className={`absolute top-3 right-3 ${getStatusColor(ride.status)} border`}
|
||||
>
|
||||
{ride.status.replace('_', ' ').toUpperCase()}
|
||||
</Badge>
|
||||
|
||||
{/* Description */}
|
||||
{ride.description && (
|
||||
<p className="text-sm text-muted-foreground line-clamp-2">
|
||||
{ride.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Category Badge */}
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{formatCategory(ride.category)}
|
||||
</Badge>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-4">
|
||||
{ride.max_speed_kmh && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="w-3 h-3 text-primary" />
|
||||
<span className="text-primary font-medium">
|
||||
<MeasurementDisplay value={ride.max_speed_kmh} type="speed" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{ride.max_height_meters && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-accent font-medium">
|
||||
<MeasurementDisplay value={ride.max_height_meters} type="distance" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{ride.duration_seconds && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3 text-secondary" />
|
||||
<span className="text-secondary font-medium">{Math.floor(ride.duration_seconds / 60)}</span>
|
||||
<span className="text-muted-foreground text-xs">min</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{ride.average_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-sm font-medium">{ride.average_rating.toFixed(1)}</span>
|
||||
<span className="text-xs text-muted-foreground">({ride.review_count})</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Button */}
|
||||
<Button
|
||||
className="w-full mt-3 bg-gradient-to-r from-primary/80 to-secondary/80 hover:from-primary hover:to-secondary transition-all duration-300"
|
||||
size="sm"
|
||||
>
|
||||
View Ride
|
||||
</Button>
|
||||
</CardContent>
|
||||
</div>
|
||||
|
||||
<CardContent className="p-4 space-y-3">
|
||||
{/* Header */}
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="font-bold text-lg group-hover:text-primary transition-colors line-clamp-1">
|
||||
{ride.name}
|
||||
</h3>
|
||||
<span className="flex items-center">{getRideIcon(ride.category)}</span>
|
||||
</div>
|
||||
|
||||
{ride.park?.name && (
|
||||
<div className="flex items-center text-sm text-muted-foreground">
|
||||
<MapPin className="w-3 h-3 mr-1" />
|
||||
{ride.park.name}
|
||||
{ride.park.location?.city && `, ${ride.park.location.city}`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
{ride.description && (
|
||||
<p className="text-sm text-muted-foreground line-clamp-2">
|
||||
{ride.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Category Badge */}
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{formatCategory(ride.category)}
|
||||
</Badge>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-4">
|
||||
{ride.max_speed_kmh && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="w-3 h-3 text-primary" />
|
||||
<span className="text-primary font-medium">
|
||||
<MeasurementDisplay value={ride.max_speed_kmh} type="speed" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{ride.max_height_meters && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-accent font-medium">
|
||||
<MeasurementDisplay value={ride.max_height_meters} type="distance" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{ride.duration_seconds && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3 text-secondary" />
|
||||
<span className="text-secondary font-medium">{Math.floor(ride.duration_seconds / 60)}</span>
|
||||
<span className="text-muted-foreground text-xs">min</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{ride.average_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-sm font-medium">{ride.average_rating.toFixed(1)}</span>
|
||||
<span className="text-xs text-muted-foreground">({ride.review_count})</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Button */}
|
||||
<Button
|
||||
className="w-full mt-3 bg-gradient-to-r from-primary/80 to-secondary/80 hover:from-primary hover:to-secondary transition-all duration-300"
|
||||
size="sm"
|
||||
>
|
||||
View Ride
|
||||
</Button>
|
||||
</CardContent>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -269,7 +275,7 @@ export function ContentTabs() {
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6">
|
||||
{popularParks.map((park) => (
|
||||
<ParkCard key={park.id} park={park} onClick={() => navigate(`/parks/${park.slug}`)} />
|
||||
<ParkCard key={park.id} park={park} />
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
@@ -281,7 +287,7 @@ export function ContentTabs() {
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6">
|
||||
{trendingParks.map((park) => (
|
||||
<ParkCard key={park.id} park={park} onClick={() => navigate(`/parks/${park.slug}`)} />
|
||||
<ParkCard key={park.id} park={park} />
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
@@ -317,7 +323,7 @@ export function ContentTabs() {
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6">
|
||||
{recentParks.map((park) => (
|
||||
<ParkCard key={park.id} park={park} onClick={() => navigate(`/parks/${park.slug}`)} />
|
||||
<ParkCard key={park.id} park={park} />
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
Reference in New Issue
Block a user