From cba02d48147c00d1a4e7ee075812102c7311af9d Mon Sep 17 00:00:00 2001 From: mahdi Date: Sat, 7 May 2022 15:49:42 +0430 Subject: [PATCH] update src/components/BoxNextToEachOther/index.js, src/components/CardTrelloDesign/index.js and src/components/ProductSuggestion/index.js --- src/components/BoxNextToEachOther/index.js | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/components/BoxNextToEachOther/index.js b/src/components/BoxNextToEachOther/index.js index bac9f46..81ae86f 100644 --- a/src/components/BoxNextToEachOther/index.js +++ b/src/components/BoxNextToEachOther/index.js @@ -2,28 +2,43 @@ import React, { useState } from "react"; import selected from "./selected.svg"; -const BoxNextToEachOther = ({ items }) => { - const [active, setActive] = useState(null); +const BoxNextToEachOther = ({ cards }) => { + // const [active, setActive] = useState(null); + const [active, setActive] = useState([]); return (
- {items.map((item, index) => ( + {cards.map((card, index) => ( + // ${active === card ? "bg-[#245CE1]" : "bg-white"}
setActive(active === item ? null : item)} + className={`relative max-w-[224px] max-h-[210px] w-44 h-44 flex flex-col items-center justify-center text-2xl border border-[#EBF4FF] rounded-md cursor-pointer + ${active.includes(card) ? "bg-[#245CE1]" : "bg-white"} + + `} + // onClick={() => setActive(active === card ? null : card)} + onClick={() => + setActive( + active.includes(card) + ? active.filter((item) => item != card) + : [...active, card] + ) + } > {console.log(setActive)}

- {item.title} + {card.title}

- {active === item && ( + {/* {active === card && ( +
+ selected-icon +
+ )} */} + {active.includes(card) && (
selected-icon
@@ -37,7 +52,7 @@ const BoxNextToEachOther = ({ items }) => { export default BoxNextToEachOther; BoxNextToEachOther.defaultProps = { - items: [ + cards: [ { title: "زائر", },