update src/components/BoxNextToEachOther/index.js, src/components/CardTrelloDesign/index.js and src/components/ProductSuggestion/index.js

master
mahdi 3 years ago
parent 7917e2206a
commit cba02d4814
  1. 41
      src/components/BoxNextToEachOther/index.js

@ -2,28 +2,43 @@ import React, { useState } from "react";
import selected from "./selected.svg"; import selected from "./selected.svg";
const BoxNextToEachOther = ({ items }) => { const BoxNextToEachOther = ({ cards }) => {
const [active, setActive] = useState(null); // const [active, setActive] = useState(null);
const [active, setActive] = useState([]);
return ( return (
<div className="w-fit flex flex-row items-center gap-x-2"> <div className="w-fit flex flex-row items-center gap-x-2">
{items.map((item, index) => ( {cards.map((card, index) => (
// ${active === card ? "bg-[#245CE1]" : "bg-white"}
<div <div
key={index} key={index}
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 ${ 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 === item ? "bg-[#245CE1]" : "bg-white" ${active.includes(card) ? "bg-[#245CE1]" : "bg-white"}
}`}
onClick={() => setActive(active === item ? null : item)} `}
// onClick={() => setActive(active === card ? null : card)}
onClick={() =>
setActive(
active.includes(card)
? active.filter((item) => item != card)
: [...active, card]
)
}
> >
{console.log(setActive)} {console.log(setActive)}
<h2 <h2
className={`font-sansbold ${ className={`font-sansbold
active === item ? "text-white" : "text-[#0F0543]" ${active.includes(card) ? "text-white" : "text-[#0F0543]"}
}`} `}
> >
{item.title} {card.title}
</h2> </h2>
{active === item && ( {/* {active === card && (
<div className="absolute left-3 top-3">
<img src={selected} alt="selected-icon" className="w-7" />
</div>
)} */}
{active.includes(card) && (
<div className="absolute left-3 top-3"> <div className="absolute left-3 top-3">
<img src={selected} alt="selected-icon" className="w-7" /> <img src={selected} alt="selected-icon" className="w-7" />
</div> </div>
@ -37,7 +52,7 @@ const BoxNextToEachOther = ({ items }) => {
export default BoxNextToEachOther; export default BoxNextToEachOther;
BoxNextToEachOther.defaultProps = { BoxNextToEachOther.defaultProps = {
items: [ cards: [
{ {
title: "زائر", title: "زائر",
}, },

Loading…
Cancel
Save