style: add skeleton loading and card animations, increase shows limit
This commit is contained in:
parent
3873ddfe8f
commit
b837d7654f
3 changed files with 53 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ def create_show(show: ShowCreate, session: Session = Depends(get_session), curre
|
||||||
@router.get("/", response_model=List[ShowRead])
|
@router.get("/", response_model=List[ShowRead])
|
||||||
def read_shows(
|
def read_shows(
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = Query(default=100, le=100),
|
limit: int = Query(default=2000, le=5000),
|
||||||
venue_id: int = None,
|
venue_id: int = None,
|
||||||
tour_id: int = None,
|
tour_id: int = None,
|
||||||
year: int = None,
|
year: int = None,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { getApiUrl } from "@/lib/api-config"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { Calendar, MapPin } from "lucide-react"
|
import { Calendar, MapPin } from "lucide-react"
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton"
|
||||||
|
|
||||||
interface Show {
|
interface Show {
|
||||||
id: number
|
id: number
|
||||||
|
|
@ -22,7 +23,7 @@ export default function ShowsPage() {
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`${getApiUrl()}/shows/?limit=50`)
|
fetch(`${getApiUrl()}/shows/?limit=2000`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
// Sort by date descending
|
// Sort by date descending
|
||||||
|
|
@ -35,10 +36,38 @@ export default function ShowsPage() {
|
||||||
.finally(() => setLoading(false))
|
.finally(() => setLoading(false))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (loading) return <div className="container py-10">Loading shows...</div>
|
if (loading) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container py-10 space-y-8">
|
<div className="container py-10 space-y-8">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-5 w-96" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
|
{Array.from({ length: 12 }).map((_, i) => (
|
||||||
|
<Card key={i} className="h-full border-muted/40">
|
||||||
|
<CardHeader>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Skeleton className="h-5 w-5 rounded-full" />
|
||||||
|
<Skeleton className="h-5 w-3/4" />
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Skeleton className="h-4 w-4 rounded-full" />
|
||||||
|
<Skeleton className="h-4 w-1/2" />
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container py-10 space-y-8 animate-in fade-in duration-700">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<h1 className="text-3xl font-bold tracking-tight">Shows</h1>
|
<h1 className="text-3xl font-bold tracking-tight">Shows</h1>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
|
|
@ -48,11 +77,11 @@ export default function ShowsPage() {
|
||||||
|
|
||||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{shows.map((show) => (
|
{shows.map((show) => (
|
||||||
<Link key={show.id} href={`/shows/${show.id}`}>
|
<Link key={show.id} href={`/shows/${show.id}`} className="block group">
|
||||||
<Card className="h-full hover:bg-accent/50 transition-colors">
|
<Card className="h-full transition-all duration-300 hover:scale-[1.02] hover:shadow-lg group-hover:border-primary/50">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center gap-2">
|
<CardTitle className="flex items-center gap-2 group-hover:text-primary transition-colors">
|
||||||
<Calendar className="h-5 w-5 text-muted-foreground" />
|
<Calendar className="h-5 w-5 text-muted-foreground group-hover:text-primary/70 transition-colors" />
|
||||||
{new Date(show.date).toLocaleDateString(undefined, {
|
{new Date(show.date).toLocaleDateString(undefined, {
|
||||||
weekday: 'long',
|
weekday: 'long',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
|
|
@ -62,7 +91,7 @@ export default function ShowsPage() {
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex items-center gap-2 text-muted-foreground">
|
<div className="flex items-center gap-2 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||||
<MapPin className="h-4 w-4" />
|
<MapPin className="h-4 w-4" />
|
||||||
<span>
|
<span>
|
||||||
{show.venue?.name}, {show.venue?.city}, {show.venue?.state}
|
{show.venue?.name}, {show.venue?.city}, {show.venue?.state}
|
||||||
|
|
|
||||||
15
frontend/components/ui/skeleton.tsx
Normal file
15
frontend/components/ui/skeleton.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Skeleton({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn("animate-pulse rounded-md bg-muted/20 dark:bg-muted/50", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Skeleton }
|
||||||
Loading…
Add table
Reference in a new issue