Skip to content

Commit

Permalink
Merge branch 'develop' into categories_navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMejia77 authored Oct 3, 2023
2 parents d3dd844 + debbee3 commit 83a7aad
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ContainerPage header={<MainCarousel />}>
{/* <CategoryCategory category={category} /> */}
<ContainerPage header={<SecondCarousel />}>
<CategoryCategory category={category} />
<TopSellers />
<BrandCarrousel />
<BrandCategory brand={brands} />
Expand Down
80 changes: 80 additions & 0 deletions src/components/carousels/secondCarousel.tsx
Original file line number Diff line number Diff line change
@@ -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<SecondCarouselProps> = ({}) => {
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 (
<div
className={`mt-[109px] md:mt-[60px] w-full h-screen m-auto relative group `}
>
<div
style={backgroundImageStyle}
className={`w-full bg-cover bg-no-repeat duration-700 ${
isMobile ? 'h-[calc(100%-109px)]' : 'h-[calc(100%-60px)]'
}`}
></div>
<div className="hidden group-hover:block absolute top-[40%] md:top-[45%] -translate-x-0 translate-y-[-50%] left-5 text-2xl rounded-full p-2 bg-white/50 text-background-dm cursor-pointer">
<BsChevronCompactLeft onClick={prevSlide} size={30} />
</div>
<div className="hidden group-hover:block absolute top-[40%] md:top-[45%] -translate-x-0 translate-y-[-50%] right-5 text-2xl rounded-full p-2 bg-white/50 text-background-dm cursor-pointer">
<BsChevronCompactRight onClick={nextSlide} size={30} />
</div>
</div>
);
};

export default SecondCarousel;
12 changes: 6 additions & 6 deletions src/components/navBar/navBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const NavBar: FC<NavBarProps> = ({}) => {
};

return (
<div>
<div className="z-50 fixed top-0 bg-opacity-70 bg-white w-full backdrop-blur-sm flex-col">
<nav className="p-4 flex items-center h-[60px] justify-between mx-auto my-1">
<nav>
<div className="z-50 fixed top-0 bg-opacity-70 bg-white w-full backdrop-blur-sm flex-col shadow-sm">
<div className="p-4 flex items-center h-[60px] justify-between mx-auto my-1">
{/* Contenedor lado izquierdo menu hamburguesa-imagenes*/}
<div className="flex items-center gap-2">
{/* Icono hamburguesa */}
Expand Down Expand Up @@ -89,7 +89,7 @@ const NavBar: FC<NavBarProps> = ({}) => {

<ThemeModeButton />
</div>
</nav>
</div>
{/* Input mobile*/}
<div className="md:hidden flex items-center justify-center pb-3 shadow-md">
<InputField
Expand All @@ -104,15 +104,15 @@ const NavBar: FC<NavBarProps> = ({}) => {
{/* Menu */}
{isOpenMenu && (
<div
className="fixed top-[108px] md:top-[60px] left-0 w-screen xs:max-w-[303px] backdrop-blur-sm bg-white bg-opacity-70 shadow-sm z-50 flex justify-center items-center"
className="fixed top-[108px] md:top-[60px] left-0 w-screen xs:max-w-[303px] backdrop-blur-sm bg-white bg-opacity-70 shadow-sm z-50 flex justify-center items-center rounded-b-md"
onMouseLeave={toggleNavbar}
>
<MenuMobile updateState={updateState} />
</div>
)}
</div>
{flagState && <Form updateState={updateState} />}
</div>
</nav>
);
};

Expand Down

0 comments on commit 83a7aad

Please sign in to comment.