-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from Actualiza-Tu-Carro/124-arreglo-category
124 arreglo category
- Loading branch information
Showing
6 changed files
with
127 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
}, | ||
] |