@@ -82,4 +83,4 @@ export default function Hero({
);
-}
+}
\ No newline at end of file
diff --git a/sections/Live Projects/ProjectsGrid.tsx b/sections/Live Projects/ProjectsGrid.tsx
index af64bd86..9e46bdc9 100644
--- a/sections/Live Projects/ProjectsGrid.tsx
+++ b/sections/Live Projects/ProjectsGrid.tsx
@@ -15,12 +15,12 @@ export interface Screenshot {
export interface Template {
label: string;
- category?: string;
description?: string;
link?: string;
image?: Screenshot[];
}
+
export interface TemplateInfo {
label?: string;
category?: string;
@@ -34,10 +34,16 @@ export interface Classification {
itensPorPagina: number;
}
-export interface Props {
- /* @default */
- indexCategories?: string[];
- cards?: Template[];
+
+interface Category {
+ label: string;
+ hideCategory?: boolean;
+ cards: Template[];
+}
+
+interface Props {
+ itensPerPage?: number;
+ indexCategories?: Category[];
layoutCategoryCard?: {
textPosition?: "top" | "bottom";
textAlignment?: "center" | "left";
@@ -45,7 +51,7 @@ export interface Props {
}
function CardText(
- { label, category, description, alignment }: TemplateInfo,
+ { label, category, description, alignment }: TemplateInfo,
) {
return (
{description && (
-
)}
+
);
}
function TemplatesGrid(props: Props) {
const id = `category-cards-${useId()}`;
const {
+ itensPerPage = 6,
indexCategories = [
- "Todos",
- "Fashion",
- "PET",
- "Farma",
- "B2B",
- "Saúde",
- "Outros",
- ],
- cards = [
{
- label: "Feminino",
- category: "MODA",
- description: "Moda feminina direto de Milão",
- link: "feminino",
- image: {
- img:
- "https://ik.imagekit.io/decocx/tr:w-680,h-680/https:/ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/239/fdcb3c8f-d629-485e-bf70-8060bd8a9f65",
- color: "",
- },
+ label: "MODA",
+ hideCategory: false,
+ cards: [
+ {
+ label: "Feminino",
+ category: "MODA",
+ description: "Moda feminina direto de Milão",
+ link: "feminino",
+ image: {
+ img: "https://ik.imagekit.io/decocx/tr:w-680,h-680/https:/ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/239/fdcb3c8f-d629-485e-bf70-8060bd8a9f65",
+ color: "",
+ },
+ },
+ {
+ label: "Invisível",
+ category: "Todos", // Marque como "Todos"
+ description: "Este card é invisível",
+ link: "invisivel",
+ image: {
+ img: "https://exemplo.com/invisivel.jpg",
+ color: "",
+ },
+ },
+ ],
},
],
layoutCategoryCard = {
@@ -122,34 +125,21 @@ function TemplatesGrid(props: Props) {
textAlignment: "center",
},
} = props;
- const [themes, setThemes] = useState(cards.map(() => 0));
+
+ const [themes, setThemes] = useState(indexCategories.flatMap(category => category.cards.map(() => 0)));
const [classification, setClassification] = useState
({
- categoriaSelecionada: "Todos",
+ categoriaSelecionada: 'Todos',
paginaAtual: 1,
- itensPorPagina: 6,
+ itensPorPagina: itensPerPage,
});
- const [mostrarCardsOutrasCategorias, setMostrarCardsOutrasCategorias] =
- useState(false);
-
const handleChangeCategoria = (novaCategoria: string) => {
- if (novaCategoria === "Outros") {
- console.log("Clicou em Outros");
- setClassification({
- categoriaSelecionada: novaCategoria,
- paginaAtual: 1,
- itensPorPagina: classification.itensPorPagina,
- });
- setMostrarCardsOutrasCategorias(true);
- } else {
- setClassification({
- categoriaSelecionada: novaCategoria,
- paginaAtual: 1,
- itensPorPagina: classification.itensPorPagina,
- });
- setMostrarCardsOutrasCategorias(false);
- }
+ setClassification({
+ categoriaSelecionada: novaCategoria,
+ paginaAtual: 1,
+ itensPorPagina: classification.itensPorPagina,
+ });
};
const handleChangePagina = (novaPagina: number) => {
@@ -162,57 +152,65 @@ function TemplatesGrid(props: Props) {
const { categoriaSelecionada, paginaAtual, itensPorPagina } = classification;
- const itensFiltrados = mostrarCardsOutrasCategorias
- ? cards.filter((item) =>
- item.category && !indexCategories.includes(item.category)
- )
- : (categoriaSelecionada === "Todos"
- ? cards
- : cards.filter((item) => item.category === categoriaSelecionada));
+ const findCategoryByLabel = (label: string, categories: { label: string }[]) => {
+ return categories.find(category => category.label === label);
+};
+
+const itensParaExibir = categoriaSelecionada === 'Todos'
+? indexCategories.flatMap(category => category.cards.map(card => ({
+ ...card,
+ category: category.label, // Adiciona o campo category ao card
+ })))
+: categoriaSelecionada
+ ? indexCategories.find(category => category.label === categoriaSelecionada)?.cards.map(card => ({
+ ...card,
+ category: categoriaSelecionada, // Adiciona o campo category ao card
+ })) || []
+ : [];
- const totalPaginas = Math.ceil(itensFiltrados.length / itensPorPagina);
+ const totalPaginas = Math.ceil(itensParaExibir.length / itensPorPagina);
const primeiroItem = (paginaAtual - 1) * itensPorPagina;
- const ultimoItem = Math.min(
- primeiroItem + itensPorPagina,
- itensFiltrados.length,
- );
- const itensPaginaAtual = itensFiltrados.slice(primeiroItem, ultimoItem);
+ const ultimoItem = Math.min(primeiroItem + itensPorPagina, itensParaExibir.length);
+ const itensPaginaAtual = itensParaExibir.slice(primeiroItem, ultimoItem);
return (
-
-