diff --git a/src/app/page.tsx b/src/app/page.tsx index 69a2b3b..90bd17c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,21 +3,21 @@ import { brands } from '~/mockData/mockBrands'; import { TopSellers } from '~/components/containerCards/containerCards'; import { createIconsTypes } from '~/utils/createIcons'; import { ContainerPage } from './container_page'; -// import CategoryCategory from '~/components/containerCards/containerCardsCategoty'; -// import { category } from '~/mockData/mockCategory'; +import CategoryCategory from '~/components/containerCards/containerCardsCategoty'; +import { category } from '~/mockData/mockCategory'; import BrandCategory from '~/components/containerCards/containerCardsBrands'; import PaymentMethodsList from '~/components/paymentMethod/paymentMethodsList'; import ReviewsContainer from '~/components/containerCards/containerCardsReviews'; import reviews from '~/mockData/mockReviwes'; import Banner from '~/components/Banner'; import BrandCarrousel from '~/components/carousels/brandCarrousel'; -import Form from '~/components/form/Form'; +import SecondCarousel from '~/components/carousels/secondCarousel'; export default function Home() { createIconsTypes(); return ( - }> - {/* */} + }> + diff --git a/src/components/carousels/secondCarousel.tsx b/src/components/carousels/secondCarousel.tsx new file mode 100644 index 0000000..a664ad8 --- /dev/null +++ b/src/components/carousels/secondCarousel.tsx @@ -0,0 +1,80 @@ +'use client'; +import React, { FC, useState, useEffect } from 'react'; +import { BsChevronCompactLeft, BsChevronCompactRight } from 'react-icons/bs'; +import { Images } from '~/assets/img'; + +interface SecondCarouselProps {} + +const slidesList = [ + { + url: 'https://user-images.githubusercontent.com/124757365/267684986-ff0802dd-37d4-496a-9665-53dd8ae362b6.png', + }, + { + url: 'https://user-images.githubusercontent.com/124757365/267684986-ff0802dd-37d4-496a-9665-53dd8ae362b6.png', + }, +]; + +const mobileSlidesList = [ + { + url: 'https://user-images.githubusercontent.com/124757365/267684987-30227360-5971-48d3-952e-ee05519a2002.png', + }, + { + url: 'https://user-images.githubusercontent.com/124757365/267684987-30227360-5971-48d3-952e-ee05519a2002.png', + }, +]; + +const SecondCarousel: FC = ({}) => { + const [currentIndex, setCurrentIndex] = useState(0); + const isMobile = window.innerWidth <= 600; + + const prevSlide = () => { + const isFirstSlide = currentIndex === 0; + const newIndex = isFirstSlide ? slidesList.length - 1 : currentIndex - 1; + setCurrentIndex(newIndex); + }; + + const nextSlide = () => { + const isLastSlide = currentIndex === slidesList.length - 1; + const newIndex = isLastSlide ? 0 : currentIndex + 1; + setCurrentIndex(newIndex); + }; + + useEffect(() => { + const interval = setInterval(() => { + nextSlide(); + }, 4000); + + return () => { + clearInterval(interval); + }; + }, [currentIndex]); + + const backgroundImageStyle = isMobile + ? { + backgroundImage: `url(${mobileSlidesList[currentIndex].url})`, + } + : { + backgroundImage: `url(${slidesList[currentIndex].url})`, + }; + + return ( +
+
+
+ +
+
+ +
+
+ ); +}; + +export default SecondCarousel; diff --git a/src/components/navBar/navBar.tsx b/src/components/navBar/navBar.tsx index 4b4a8ab..3922b35 100644 --- a/src/components/navBar/navBar.tsx +++ b/src/components/navBar/navBar.tsx @@ -22,9 +22,9 @@ const NavBar: FC = ({}) => { }; return ( -
+ ); };