From cb0309586025e3ce70f3985d0ebb0c1318810181 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 27 Oct 2023 15:53:32 -0300 Subject: [PATCH] feat(stackedComponents): add ElementStack component to create a stacked effect for child components fix(market-card): refactor tagsPopUp to use ElementStack component for a stacked effect --- .../components/stackedComponents/index.tsx | 25 ++++++++ .../StorePage/components/market-card.tsx | 60 +++++++++++++++---- 2 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 src/frontend/src/components/stackedComponents/index.tsx diff --git a/src/frontend/src/components/stackedComponents/index.tsx b/src/frontend/src/components/stackedComponents/index.tsx new file mode 100644 index 000000000..000dba85d --- /dev/null +++ b/src/frontend/src/components/stackedComponents/index.tsx @@ -0,0 +1,25 @@ +import React, { ReactNode } from "react"; + +interface ElementStackProps { + children: ReactNode[]; +} + +const ElementStack: React.FC = ({ children }) => { + return ( +
+ {children.map((child, index) => ( +
+ {child} +
+ ))} +
+ ); +}; + +export default ElementStack; diff --git a/src/frontend/src/pages/StorePage/components/market-card.tsx b/src/frontend/src/pages/StorePage/components/market-card.tsx index 4deca30dd..335b92af1 100644 --- a/src/frontend/src/pages/StorePage/components/market-card.tsx +++ b/src/frontend/src/pages/StorePage/components/market-card.tsx @@ -1,6 +1,7 @@ import { ReactNode, useContext, useEffect, useRef, useState } from "react"; import ShadTooltip from "../../../components/ShadTooltipComponent"; import IconComponent from "../../../components/genericIconComponent"; +import ElementStack from "../../../components/stackedComponents"; import { Badge } from "../../../components/ui/badge"; import { Button } from "../../../components/ui/button"; import { @@ -26,19 +27,23 @@ export const MarketCardComponent = ({ data }: { data: storeComponent }) => { const { setSuccessData, setErrorData } = useContext(alertContext); const flowData = useRef(); const tagsPopUp = useRef(null); - + const testTags = ["teste", "teste2", "teste3"]; useEffect(() => { //@ts-ignore tagsPopUp.current = ( -
- Tags -
- {["teste"].map((tag) => ( - +
+ {testTags.map((tag, index) => ( +
+ {tag} - ))} -
+
+ ))}
); }, []); @@ -141,10 +146,41 @@ export const MarketCardComponent = ({ data }: { data: storeComponent }) => {
- - - {data.tags.length > 0 ? "teste" : "-"} - + + {testTags.map((tag, index) => ( +
+ + {tag} + +
+ ))} +
+ } + > +
+ {data.tags.length > 0 ? ( + + {data.tags.map((tag, index) => ( + + {"tag"} + + ))} + + ) : ( + + - + + )} +