You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.0 KiB

3 years ago
import React, { useState } from "react";
import filter from "./filter.svg";
import plus from "./plus.svg";
import more from "./more2.svg";
3 years ago
import DropDown from "./DropDown";
3 years ago
export function EditButtons({ buttons }) {
const [selectedButton, setSelectedButton] = useState(null);
return (
3 years ago
<div className="flex flex-row items-center justify-end ">
3 years ago
{buttons.map((button, index) => (
<div>
3 years ago
<div
3 years ago
className={`flex flex-row items-center justify-around p-1 rounded-md bg-opacity-30 mx-1 ${
3 years ago
button.border
} ${button.borderColor} ${
selectedButton === button ? "border" : "border-0"
}`}
key={index}
style={{
backgroundColor: button.backgroundColor,
padding: button.padding,
}}
onClick={() =>
setSelectedButton(selectedButton === button ? null : button)
}
>
<p className={` text-white`}>{button.title}</p>
<img
src={button.logo}
alt=""
className={`cursor-pointer ${button.width} ${button.height} ${
button.title === null ? "mr-0" : "mx-2"
}`}
/>
</div>
</div>
))}
3 years ago
<div>{selectedButton?.components}</div>
3 years ago
</div>
);
}
EditButtons.defaultProps = {
buttons: [
{
logo: plus,
width: "w-3",
height: "h-3",
title: "ثبت جدید",
backgroundColor: "#65A9FF",
border: "border-b-4",
borderColor: "#3686EC",
padding: "4px 7px",
3 years ago
// components: "d",
3 years ago
},
{
logo: filter,
width: "w-5",
height: "h-5",
title: null,
backgroundColor: "#F3F8FF",
border: null,
borderColor: null,
3 years ago
// components: "a",
3 years ago
},
{
logo: more,
width: "w-5",
height: "h-5",
title: null,
textColor: null,
backgroundColor: "#F3F8FF",
border: null,
borderColor: null,
3 years ago
// components: <DropDown />,
3 years ago
},
],
};