71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import {
|
|
Carousel,
|
|
CarouselContent,
|
|
CarouselItem,
|
|
type CarouselApi,
|
|
} from "@/components/ui/carousel"
|
|
import Image from "next/image"
|
|
|
|
export function RepairsImageCarousel() {
|
|
const [api, setApi] = React.useState<CarouselApi>()
|
|
const [current, setCurrent] = React.useState(0)
|
|
|
|
React.useEffect(() => {
|
|
if (!api) return
|
|
|
|
setCurrent(api.selectedScrollSnap())
|
|
|
|
api.on("select", () => {
|
|
setCurrent(api.selectedScrollSnap())
|
|
})
|
|
}, [api])
|
|
|
|
React.useEffect(() => {
|
|
if (!api) return
|
|
|
|
const interval = setInterval(() => {
|
|
api.scrollNext()
|
|
}, 4000)
|
|
|
|
return () => clearInterval(interval)
|
|
}, [api])
|
|
|
|
return (
|
|
<Carousel
|
|
setApi={setApi}
|
|
className="w-full"
|
|
opts={{
|
|
align: "start",
|
|
loop: true,
|
|
}}
|
|
>
|
|
<CarouselContent>
|
|
<CarouselItem className="md:basis-1/2">
|
|
<div className="relative aspect-video overflow-hidden rounded-[1.5rem] border border-border/60 shadow-[0_16px_40px_rgba(15,23,42,0.08)]">
|
|
<Image
|
|
src="https://rockymountainvending.com/wp-content/uploads/2025/09/IMG_4660-scaled.jpeg"
|
|
alt="Vending machine repair service"
|
|
fill
|
|
className="object-cover"
|
|
sizes="(max-width: 768px) 100vw, 50vw"
|
|
/>
|
|
</div>
|
|
</CarouselItem>
|
|
<CarouselItem className="md:basis-1/2">
|
|
<div className="relative aspect-video overflow-hidden rounded-[1.5rem] border border-border/60 shadow-[0_16px_40px_rgba(15,23,42,0.08)]">
|
|
<Image
|
|
src="https://rockymountainvending.com/wp-content/uploads/2025/09/IMG_4676-scaled.jpeg"
|
|
alt="Vending machine maintenance"
|
|
fill
|
|
className="object-cover"
|
|
sizes="(max-width: 768px) 100vw, 50vw"
|
|
/>
|
|
</div>
|
|
</CarouselItem>
|
|
</CarouselContent>
|
|
</Carousel>
|
|
)
|
|
}
|