Files
otunes/apps/web/components/content-carousel.tsx
T
joshuafhiggins 73c7283d4d Add Expo mobile app and extract shared Convex package
- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library)
- Move Convex backend to @otunes/convex for web and mobile reuse
- Update web app imports and API routes to use shared package
2026-08-02 04:14:01 +00:00

92 lines
2.7 KiB
TypeScript

"use client"
import Link from "next/link"
import { ChevronRightIcon } from "lucide-react"
import { AlbumCard } from "@/components/album-card"
import type {
BrowseAlbum,
BrowseArtist,
PlaylistSummary,
} from "@otunes/convex/types"
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel"
import { cn } from "@/lib/utils"
import { ArtistCard } from "./artist-card"
import { PlaylistCard } from "./playlist-card"
function CarouselCard({
item,
}: {
item: BrowseAlbum | BrowseArtist | PlaylistSummary
}) {
if ("owner" in item) {
return <PlaylistCard playlist={item} />
}
if ("artist" in item) {
return <AlbumCard album={item} />
}
return <ArtistCard artist={item} />
}
export function ContentCarousel({
title,
href,
content,
className,
slideClassName = "basis-1/2 pl-4 sm:basis-1/3 md:basis-1/4 lg:basis-1/5 xl:basis-1/6",
carouselContentClassName,
}: {
title: string
href?: string
content: (BrowseAlbum | BrowseArtist | PlaylistSummary)[]
className?: string
slideClassName?: string
carouselContentClassName?: string
}) {
return (
<section className={cn("flex min-w-0 flex-col gap-4", className)}>
{href ? (
<Link
href={href}
className="group inline-flex w-fit items-center gap-1 text-xl font-bold tracking-tight"
>
{title}
<ChevronRightIcon className="size-5 text-muted-foreground transition-transform group-hover:translate-x-0.5" />
</Link>
) : (
<h2 className="text-xl font-bold tracking-tight">{title}</h2>
)}
<Carousel
opts={{
align: "start",
dragFree: true,
containScroll: false,
slidesToScroll: 5,
}}
className="relative min-w-0"
>
<CarouselContent
className={cn("w-full", carouselContentClassName)}
>
{content.map((item) => (
<CarouselItem key={item.id} className={slideClassName}>
<CarouselCard item={item} />
</CarouselItem>
))}
</CarouselContent>
<div className="pointer-events-none absolute top-1/2 flex w-1/2 -translate-y-1/2 justify-between sm:w-2/3 md:w-3/4 lg:w-4/5 xl:w-5/6">
<CarouselPrevious className="relative -left-4 h-16 w-6 bg-primary/90 opacity-0 pointer-events-none hover:pointer-events-auto hover:opacity-100 disabled:pointer-events-none disabled:opacity-0" />
<CarouselNext className="relative -right-2 h-16 w-6 bg-primary/90 opacity-0 pointer-events-none hover:pointer-events-auto hover:opacity-100 disabled:pointer-events-none disabled:opacity-0" />
</div>
</Carousel>
</section>
)
}