mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:31:13 -05:00
Refactor ride cards
This commit is contained in:
@@ -2,7 +2,9 @@ import { useState, useEffect } from 'react';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { ParkCard } from '@/components/parks/ParkCard';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Star, TrendingUp, Plus, MapPin } from 'lucide-react';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Star, TrendingUp, Plus, MapPin, Clock, Zap } from 'lucide-react';
|
||||
import { Park, Ride } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
|
||||
@@ -76,51 +78,137 @@ export function ContentTabs() {
|
||||
}
|
||||
};
|
||||
|
||||
const getRideIcon = (category: string) => {
|
||||
switch (category) {
|
||||
case 'roller_coaster': return '🎢';
|
||||
case 'water_ride': return '🌊';
|
||||
case 'dark_ride': return '🎭';
|
||||
case 'flat_ride': return '🎡';
|
||||
case 'kiddie_ride': return '🎠';
|
||||
case 'transportation': return '🚂';
|
||||
default: return '🎢';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
case 'operating': return 'bg-green-500/20 text-green-400 border-green-500/30';
|
||||
case 'seasonal': return 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30';
|
||||
case 'under_construction': return 'bg-blue-500/20 text-blue-400 border-blue-500/30';
|
||||
default: return 'bg-red-500/20 text-red-400 border-red-500/30';
|
||||
}
|
||||
};
|
||||
|
||||
const formatCategory = (category: string) => {
|
||||
return category.split('_').map(word =>
|
||||
word.charAt(0).toUpperCase() + word.slice(1)
|
||||
).join(' ');
|
||||
};
|
||||
|
||||
const RideCard = ({ ride }: { ride: Ride }) => (
|
||||
<Card className="group hover:shadow-lg transition-all duration-300 cursor-pointer">
|
||||
<CardContent className="p-4">
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<h3 className="font-semibold group-hover:text-primary transition-colors line-clamp-1">
|
||||
<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]"
|
||||
>
|
||||
<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="text-6xl opacity-50">
|
||||
{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>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
at {ride.park?.name}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{ride.category === 'roller_coaster' ? '🎢' :
|
||||
ride.category === 'water_ride' ? '🌊' :
|
||||
ride.category === 'dark_ride' ? '🎭' : '🎡'}
|
||||
<span className="text-xl">{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-3">
|
||||
<div className="flex items-center gap-4">
|
||||
{ride.max_speed_kmh && (
|
||||
<span className="text-primary font-medium">{ride.max_speed_kmh} km/h</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="w-3 h-3 text-primary" />
|
||||
<span className="text-primary font-medium">{ride.max_speed_kmh}</span>
|
||||
<span className="text-muted-foreground text-xs">km/h</span>
|
||||
</div>
|
||||
)}
|
||||
{ride.max_height_meters && (
|
||||
<span className="text-secondary font-medium">{ride.max_height_meters}m</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-accent font-medium">{ride.max_height_meters}</span>
|
||||
<span className="text-muted-foreground text-xs">m</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="font-medium">{ride.average_rating.toFixed(1)}</span>
|
||||
<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>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
{/* 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>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user