|
1 | | -import React, { useState } from "react"; |
2 | | -import { BsChevronCompactLeft, BsChevronCompactRight } from "react-icons/bs"; |
3 | | -import { RxDotFilled } from "react-icons/rx"; |
4 | | -import { useLocation } from "react-router-dom"; |
5 | | -export function Carousel() { |
6 | | - const slides = [ |
7 | | - { |
8 | | - url: "https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Mano-humana-y-robo%CC%81tica-tocan-un-cerebro-digital-1.jpg?w=1280&ssl=1", |
9 | | - }, |
10 | | - { |
11 | | - url: "https://i1.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Steve-Jobs-presenta-el-primer-iPhone-en-2007-1.jpg?w=1280&ssl=1", |
12 | | - }, |
13 | | - { |
14 | | - url: "https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Mujer-immersa-en-videojuego-con-realidad-virtual.jpg?w=1280&ssl=1", |
15 | | - }, |
| 1 | +'use client'; |
16 | 2 |
|
17 | | - { |
18 | | - url: "https://images.unsplash.com/photo-1512756290469-ec264b7fbf87?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2253&q=80", |
19 | | - }, |
20 | | - { |
21 | | - url: "https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Coche-auto%CC%81nomo-con-HUD-Head-Up-Display.-Vehi%CC%81culo-auto%CC%81nomo-en-las-calles-de-la-ciudad.png?w=1280&ssl=1", |
22 | | - }, |
23 | | - ]; |
| 3 | +import { Carousel } from 'flowbite-react'; |
24 | 4 |
|
25 | | - const [currentIndex, setCurrentIndex] = useState(0); |
26 | | - |
27 | | - const prevSlide = () => { |
28 | | - const isFirstSlide = currentIndex === 0; |
29 | | - const newIndex = isFirstSlide ? slides.length - 1 : currentIndex - 1; |
30 | | - setCurrentIndex(newIndex); |
31 | | - }; |
32 | | - |
33 | | - const nextSlide = () => { |
34 | | - const isLastSlide = currentIndex === slides.length - 1; |
35 | | - const newIndex = isLastSlide ? 0 : currentIndex + 1; |
36 | | - setCurrentIndex(newIndex); |
37 | | - }; |
38 | | - |
39 | | - const goToSlide = (slideIndex) => { |
40 | | - setCurrentIndex(slideIndex); |
41 | | - }; |
42 | | - const location = useLocation(); |
43 | | - const isHomePage = location.pathname === "/"; |
44 | | - if (!isHomePage) { |
45 | | - return null; |
46 | | - } |
| 5 | +export function DefaultCarousel() { |
47 | 6 | return ( |
48 | | - <div className="max-w-[50] h-[500px] w-90 m-auto py-16 px-10 relative group animate-fade-right animate-once animate-duration-[500ms] animate-ease-out"> |
49 | | - <div |
50 | | - style={{ backgroundImage: `url(${slides[currentIndex].url})` }} |
51 | | - className="w-full h-full rounded bg-center bg-cover duration-500" |
52 | | - ></div> |
| 7 | + <Carousel> |
| 8 | + <img |
| 9 | + alt="..." |
| 10 | + src="https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Mano-humana-y-robo%CC%81tica-tocan-un-cerebro-digital-1.jpg?w=1280&ssl=1" |
| 11 | + /> |
| 12 | + <img |
| 13 | + alt="..." |
| 14 | + src="https://i1.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Steve-Jobs-presenta-el-primer-iPhone-en-2007-1.jpg?w=1280&ssl=1" |
| 15 | + /> |
| 16 | + <img |
| 17 | + alt="..." |
| 18 | + src="https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Mujer-immersa-en-videojuego-con-realidad-virtual.jpg?w=1280&ssl=1" |
| 19 | + /> |
| 20 | + <img |
| 21 | + alt="..." |
| 22 | + src="https://images.unsplash.com/photo-1512756290469-ec264b7fbf87?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2253&q=80" |
| 23 | + /> |
| 24 | + <img |
| 25 | + alt="..." |
| 26 | + src="https://i2.wp.com/www.revistamercado.do/wp-content/uploads/2021/08/Coche-auto%CC%81nomo-con-HUD-Head-Up-Display.-Vehi%CC%81culo-auto%CC%81nomo-en-las-calles-de-la-ciudad.png?w=1280&ssl=1" |
| 27 | + /> |
| 28 | + </Carousel> |
| 29 | + ) |
| 30 | +} |
53 | 31 |
|
54 | | - <div className="hidden group-hover:block absolute top-[50%] -translate-x-0 translate-y-[-50%] left-5 text-2xl rounded-full p-2 bg-black/20 text-white cursor-pointer"> |
55 | | - <BsChevronCompactLeft onClick={prevSlide} size={30} /> |
56 | | - </div> |
57 | 32 |
|
58 | | - <div className="hidden group-hover:block absolute top-[50%] -translate-x-0 translate-y-[-50%] right-5 text-2xl rounded-full p-2 bg-black/20 text-white cursor-pointer"> |
59 | | - <BsChevronCompactRight onClick={nextSlide} size={30} /> |
60 | | - </div> |
61 | | - <div className="flex top-4 justify-center py-2"> |
62 | | - {slides.map((slide, slideIndex) => ( |
63 | | - <div |
64 | | - key={slideIndex} |
65 | | - onClick={() => goToSlide(slideIndex)} |
66 | | - className="text-2xl cursor-pointer" |
67 | | - > |
68 | | - <RxDotFilled /> |
69 | | - </div> |
70 | | - ))} |
71 | | - </div> |
72 | | - </div> |
73 | | - ); |
74 | | -} |
0 commit comments