|
| 1 | +import { Carousel } from 'primereact/carousel'; |
| 2 | +import * as React from 'react'; |
| 3 | + |
| 4 | +const images = [ |
| 5 | + 'https://images.unsplash.com/photo-1589656966895-2f33e7653819?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 6 | + 'https://images.unsplash.com/photo-1518717758536-85ae29035b6d?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 7 | + 'https://images.unsplash.com/photo-1704905832963-37d6f12654b7?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 8 | + 'https://images.unsplash.com/photo-1470130623320-9583a8d06241?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 9 | + 'https://images.unsplash.com/photo-1678841446310-d045487ef299?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 10 | + 'https://images.unsplash.com/photo-1497752531616-c3afd9760a11?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 11 | + 'https://images.unsplash.com/photo-1511885663737-eea53f6d6187?q=80&w=1374&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 12 | + 'https://images.unsplash.com/photo-1598439210625-5067c578f3f6?q=80&w=1472&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', |
| 13 | + 'https://images.unsplash.com/photo-1638255402906-e838358069ab?q=80&w=1631&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' |
| 14 | +]; |
| 15 | + |
| 16 | +function GalleryDemo() { |
| 17 | + const [selectedImage, setSelectedImage] = React.useState(0); |
| 18 | + |
| 19 | + return ( |
| 20 | + <div className="mt-8 mb-16"> |
| 21 | + <div className="max-w-3xl mx-auto"> |
| 22 | + <Carousel slide={selectedImage} onSlideChange={(e) => setSelectedImage(e.value)}> |
| 23 | + <Carousel.Content className="h-[400px]"> |
| 24 | + {images.map((_, i) => ( |
| 25 | + <Carousel.Item key={i}> |
| 26 | + <div className="p-1 h-full"> |
| 27 | + <img src={images[i]} alt={`Image ${i + 1}`} draggable={false} className="h-full w-full object-cover select-none" /> |
| 28 | + </div> |
| 29 | + </Carousel.Item> |
| 30 | + ))} |
| 31 | + </Carousel.Content> |
| 32 | + |
| 33 | + <Carousel className="mt-4" spacing={4} align="center" slide={selectedImage}> |
| 34 | + <Carousel.Content className="h-[90px]"> |
| 35 | + {images.map((_, i) => ( |
| 36 | + <Carousel.Item key={i} size={20} onClick={() => setSelectedImage(i)} className={`cursor-pointer transition-opacity ${selectedImage === i ? '' : 'opacity-60 hover:opacity-40'}`}> |
| 37 | + <div className="p-1 h-full"> |
| 38 | + <img src={images[i]} alt={`Image ${i + 1}`} draggable={false} className="h-full w-full object-cover select-none" /> |
| 39 | + </div> |
| 40 | + </Carousel.Item> |
| 41 | + ))} |
| 42 | + </Carousel.Content> |
| 43 | + </Carousel> |
| 44 | + </Carousel> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + ); |
| 48 | +} |
| 49 | + |
| 50 | +export default GalleryDemo; |
0 commit comments