Skip to content

Commit

Permalink
Merge pull request #125 from Actualiza-Tu-Carro/124-arreglo-category
Browse files Browse the repository at this point in the history
124 arreglo category
  • Loading branch information
duvan29 authored Sep 8, 2023
2 parents 66d9486 + 4e72384 commit 7edf404
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 154 deletions.
2 changes: 1 addition & 1 deletion src/app/container_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function ContainerPage({
<>
{typeof nav === 'boolean' && nav ? <NavBar /> : nav}
{header && header}
<main className="min-h-screen overflow-hidden mx-auto max-w-7xl px-4">
<main className="min-h-screen overflow-hidden mx-auto">
{children}
</main>
{footer && <Footer />}
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default function Home() {
createIconsTypes();
return (
<ContainerPage header={<MainCarousel />}>
<CategoryCategory category={category} />
<PaymentMethodsList />
<ContainerCard products={productos} />
<CategoryCategory category={category} />
<BrandCategory brand={brands} />
</ContainerPage>
);
Expand Down
93 changes: 64 additions & 29 deletions src/assets/img/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Importa las imágenes de la carpeta 'logo'
import LogoATCBubbleBlack from './logo/LogoATCBubbleBlack.webp';
import LogoCarBlack from './logo/LogoATCCarBlack.webp';
import LogoCarRed from './logo/LogoATCCarRed.webp';
Expand All @@ -7,14 +8,20 @@ import LogoRedColor from './logo/LogoATCRedColor.webp';
import LogoShieldBlack from './logo/LogoATCShieldBlack.webp';
import LogoShieldLight from './logo/LogoATCShieldLight.webp';
import LogoShieldRed from './logo/LogoATCShieldRed.webp';

// Importa las imágenes de la carpeta 'iconsImg'
import CompraSegura from './iconsImg/IconCompraSegura.webp';
import GarantiaServicioCliente from './iconsImg/IconGarantiaServicoAlCliente.webp';
import SelloGarantia from './iconsImg/SelloGarantia.webp';
import FaviconRed from './favicon/FaviconRed.webp'

// Importa las imágenes de la carpeta 'favicon'
import FaviconRed from './favicon/FaviconRed.webp';
import FaviconRedWhite from './favicon/FaviconRedWhite.webp';
import BannerCarrucelFarolas from './banners/BannerCarucelFarolas.webp'

// Importa las imágenes de la carpeta 'banners'
import BannerCarrucelFarolas from './banners/BannerCarucelFarolas.webp';
import BannerCarrucelMainCategory from './banners/BannerCarucelMainCategory.webp';
import BannerCarucelMainCategoryWithLogo from './banners/BannerCarucelMainCategoryWithLogo.webp'
import BannerCarucelMainCategoryWithLogo from './banners/BannerCarucelMainCategoryWithLogo.webp';
import BannnerCarrucelMainCategoryWhithLogo2 from './banners/BannerCarucelMainCategoryWithLogo2.webp';
import BannerCategoryCarRed from './banners/BannerCategoryCarRed.webp';
import BannerCarGreyLogo from './banners/BannerCategoryCarGreyLogo.webp';
Expand All @@ -24,31 +31,59 @@ import CategoryFarolas from './banners/CategoryFarolas.webp';
import FlyerCategores from './banners/FlyerCategories.webp';
import LogoCardBanner from './banners/LogoCardBanner.webp';

// Importa las imágenes de la carpeta 'categories'
import Cat01 from './categories/Cat01.png';
import Cat02 from './categories/Cat02.png';
import Cat03 from './categories/Cat03.png';
import Cat04 from './categories/Cat04.png';
import Cat05 from './categories/Cat05.png';
import Cat06 from './categories/Cat06.png';
import Cat07 from './categories/Cat07.png';
import Cat08 from './categories/Cat08.png';

// Exporta todas las imágenes organizadas en un objeto
export const Images = {
LogoATCBubbleBlack,
LogoCarBlack,
LogoCarRed,
LogoDarkMode,
LogoLightMode,
LogoRedColor,
LogoShieldBlack,
LogoShieldLight,
LogoShieldRed,
GarantiaServicioCliente,
CompraSegura,
SelloGarantia,
FaviconRed,
FaviconRedWhite,
BannerCarrucelFarolas,
BannerCarrucelMainCategory,
BannerCarucelMainCategoryWithLogo,
BannnerCarrucelMainCategoryWhithLogo2,
BannerCategoryCarRed,
BannerCarGreyLogo,
BannerDelivery,
BannerWomenAndCar,
CategoryFarolas,
FlyerCategores,
LogoCardBanner
};
logos: {
LogoATCBubbleBlack,
LogoCarBlack,
LogoCarRed,
LogoDarkMode,
LogoLightMode,
LogoRedColor,
LogoShieldBlack,
LogoShieldLight,
LogoShieldRed,
},
icons: {
CompraSegura,
GarantiaServicioCliente,
SelloGarantia,
},
favicon: {
FaviconRed,
FaviconRedWhite,
},
banners: {
BannerCarrucelFarolas,
BannerCarrucelMainCategory,
BannerCarucelMainCategoryWithLogo,
BannnerCarrucelMainCategoryWhithLogo2,
BannerCategoryCarRed,
BannerCarGreyLogo,
BannerDelivery,
BannerWomenAndCar,
CategoryFarolas,
FlyerCategores,
LogoCardBanner,
},
categories: {
Cat01,
Cat02,
Cat03,
Cat04,
Cat05,
Cat06,
Cat07,
Cat08,
},
};
31 changes: 13 additions & 18 deletions src/components/cards/categoryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
import React, { FC } from "react";
import Image from "next/image";

interface CardPropsCategory {
name: string;
description: string;
imageSrc: string;
}

const CardCategory: FC<CardPropsCategory> = ({ name, description, imageSrc }) => {
const CardCategory: FC<CardPropsCategory> = ({ name, imageSrc }) => {
return (
<div className="flex justify-start items-center w-[46%] h-[300px] ml-8 mr-8 mt-10 bg-inherit overflow-hidden hover:bg-primary-lm hover:text-secondary-background">
<div className="flex-shrink-0 w-[55%] p-[0.625rem]">
<h3 className="font-bold text-5xl mb-5 line-clamp-2 ">
{name}
</h3>
<p className="text-lg overflow-hidden">
{description}
</p>
</div>
<div className=" w-[55%] bg-secondary-background h-[100%] flex justify-start ">
<img
<div className="flex w-[10rem] h-[200px] flex-col items-center overflow-hidden m-8">
<div className="w-full h-[78%] relative">
<Image
src={imageSrc}
alt="Imagen de Categoria"
className="w-full h-[15.625rem]"
style={{ alignSelf: "center", marginLeft: "auto" }}
layout="fill"
objectFit="cover"
/>
</div>
<div>
<h3 className="font-bold text-2xl w-[100%] h-[22%] mt-2">
{name}
</h3>
</div>
</div>
);
};

export default CardCategory;


export default CardCategory;
42 changes: 2 additions & 40 deletions src/components/containerCards/containerCardsCategoty.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,31 @@
'use client';
import React from "react";
import CardCategory from "../cards/categoryCard";
import { useState } from 'react';
import Pagination from '../pagination';


type Category = {
id: string;
name: string;
image: string[];
description: string;
};

type ContainerCardProps = {
category: Category[];
};

const CategoryCategory = ({ category }: ContainerCardProps) => {

const [pagination, setPagination] = useState({
page: 1,
itemsPage: 4,
});

const maximo = Math.ceil(category.length / pagination.itemsPage);
const startIndex = (pagination.page - 1) * pagination.itemsPage;
const endIndex = startIndex + pagination.itemsPage;

const anteriorSiguiente = (action: 'Anterior' | 'Siguiente') => {
if (action === 'Anterior')
setPagination({
...pagination,
page: pagination.page - 1,
});
else if (action === 'Siguiente')
setPagination({
...pagination,
page: pagination.page + 1,
});
};

return (
<div>
<h1 className='title'>
Categorías
</h1>
<div className="flex flex-wrap justify-center">
{category.slice(startIndex, endIndex).map((category) => (
<div className="flex flex-wrap justify-around mt-12">
{category.map((category) => (
<CardCategory
key={category.id}
name={category.name}
imageSrc={category.image[0]}
description={category.description}
/>
))}
</div>
<div className="flex justify-center items-center text-center my-8">
<Pagination
page={pagination.page}
anteriorSiguiente={anteriorSiguiente}
maximo={maximo}
/>
</div>
</div>
);
};

export default CategoryCategory;
111 changes: 46 additions & 65 deletions src/mockData/mockCategory.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,51 @@
type Category = {
id: string;
name: string;
image: string[];
description: string;
};
import { StaticImageData } from 'next/image';
import { Images } from '~/assets/img';

type Category = {
id: string;
name: string;
image: StaticImageData[];
};

export const category: Category[] = [
{
id: '1',
name: 'Farolas',
image: ['https://i.ebayimg.com/images/g/rcgAAOSw~2Jjhupf/s-l1600.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '2',
name: 'Stops',
image: ['https://i.postimg.cc/hGXcvMz4/H-i3r.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '3',
name: 'Exploradoras',
image: ['https://grancupon.com/53-large_default/2-exploradoras-de-6-led-para-carros-y-motos.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '4',
name: 'Parrillas',
image: ['https://lujosyaccesoriostincars.com/wp-content/uploads/2020/12/Portaequipaje-Parrilla.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '5',
name: 'Bompers',
image: ['https://gruporevisa.net/cdn/shop/collections/bumper-delantero-auto-repuestos-revisa.jpg?v=1660411105'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '6',
name: 'Bombillos',
image: ['https://voyyo.com.co/uploads/shop/img/901ba4e257c8655a5e949316781206a4.jpeg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '7',
name: 'Spoilers',
image: ['https://i.pinimg.com/236x/e3/6f/4f/e36f4f00ce2b399210822f5441c6ae36--spoiler-deck.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '8',
name: 'Accesorios',
image: ['https://images-na.ssl-images-amazon.com/images/I/61-s1ysqZML._AC_UL330_SR330,330_.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '9',
name: 'Repuestos',
image: ['https://www.pruebaderuta.com/wp-content/uploads/2017/02/repuestos.jpg'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
{
id: '10',
name: 'Radios',
image: ['https://http2.mlstatic.com/D_NQ_NP_609214-MCO44055199470_112020-O.webp'],
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio in et, lectus sit lorem id integer."
},
id: '1',
name: 'Farolas',
image: [Images.categories.Cat04],
},
{
id: '2',
name: 'Stops',
image: [Images.categories.Cat05],
},
{
id: '3',
name: 'Audio',
image: [Images.categories.Cat07],
},
{
id: '4',
name: 'Exploradoras',
image: [Images.categories.Cat06],
},
{
id: '5',
name: 'Exterior',
image: [Images.categories.Cat02],
},
{
id: '6',
name: 'Interior',
image: [Images.categories.Cat08],
},
{
id: '7',
name: 'Bombillos',
image: [Images.categories.Cat03],
},
{
id: '8',
name: 'Repuestos',
image: [Images.categories.Cat01],
},
]

0 comments on commit 7edf404

Please sign in to comment.