parent
3d7b682af9
commit
07adbd86cd
3 changed files with 53 additions and 4 deletions
@ -1,11 +1,54 @@ |
|||||||
import React from "react"; |
import React, { useState } from "react"; |
||||||
|
|
||||||
const BoxNextToEachOther = () => { |
import selected from "./selected.svg"; |
||||||
return <div>BoxNextToEachOther</div>; |
|
||||||
|
const BoxNextToEachOther = ({ items }) => { |
||||||
|
const [active, setActive] = useState(null); |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="flex flex-row items-center mx-auto justify-between max-w-[750px] "> |
||||||
|
{items.map((item, index) => ( |
||||||
|
<div |
||||||
|
key={index} |
||||||
|
className={`relative flex flex-col items-center justify-center text-2xl max-w-[224px] max-h-[210px] w-44 h-44 border border-[#EBF4FF] rounded-md cursor-pointer ${ |
||||||
|
active === item ? "bg-[#245CE1]" : "bg-white" |
||||||
|
}`}
|
||||||
|
onClick={() => setActive(active === item ? null : item)} |
||||||
|
> |
||||||
|
{console.log(setActive)} |
||||||
|
<h2 |
||||||
|
className={`font-bold ${ |
||||||
|
active === item ? "text-white" : "text-[#0F0543]" |
||||||
|
}`}
|
||||||
|
> |
||||||
|
{item.title} |
||||||
|
</h2> |
||||||
|
{active === item && ( |
||||||
|
<div className="absolute left-3 top-3"> |
||||||
|
<img src={selected} alt="selected-icon" className="w-7" /> |
||||||
|
</div> |
||||||
|
)} |
||||||
|
</div> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
); |
||||||
}; |
}; |
||||||
|
|
||||||
export default BoxNextToEachOther; |
export default BoxNextToEachOther; |
||||||
|
|
||||||
BoxNextToEachOther.defaultProps = { |
BoxNextToEachOther.defaultProps = { |
||||||
items: [{}], |
items: [ |
||||||
|
{ |
||||||
|
title: "زائر", |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: "خادم", |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: "ایرانی", |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: "غیر ایرانی", |
||||||
|
}, |
||||||
|
], |
||||||
}; |
}; |
||||||
|
After Width: | Height: | Size: 448 B |
Loading…
Reference in new issue