frontPanel/src/ui_kit/AddOrEditImageButton.tsx

65 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-10-19 10:34:48 +00:00
import Plus from "@icons/questionsPage/plus";
2023-10-23 15:21:34 +00:00
import { Box, Button, SxProps, Theme } from "@mui/material";
2023-10-19 10:34:48 +00:00
import Image from "../assets/icons/questionsPage/image";
interface Props {
sx?: SxProps<Theme>;
imageSrc?: string;
onImageClick?: () => void;
onPlusClick?: () => void;
}
export default function AddOrEditImageButton({ onImageClick, onPlusClick, sx, imageSrc }: Props) {
return (
<Box sx={{
display: "flex",
height: "40px",
minWidth: "60px",
width: "60px",
borderRadius: "3px",
overflow: "hidden",
...sx,
}}>
2023-10-23 15:21:34 +00:00
<Button
2023-10-19 10:34:48 +00:00
onClick={onImageClick}
sx={{
2023-10-23 15:21:34 +00:00
p: 0,
minWidth: "40px",
2023-10-19 10:34:48 +00:00
flexGrow: 1,
backgroundColor: "#EEE4FC",
}}>
{imageSrc ? (
<img
src={imageSrc}
alt=""
style={{
width: "100%",
height: "100%",
objectFit: "scale-down",
display: "block",
}}
/>
) : (
<Image sx={{
height: "100%",
width: "100%",
}} />
)}
2023-10-23 15:21:34 +00:00
</Button>
<Button
2023-10-19 10:34:48 +00:00
onClick={onPlusClick}
2023-11-04 17:04:24 +00:00
data-cy="add-variant-image-button"
2023-10-19 10:34:48 +00:00
sx={{
2023-10-23 15:21:34 +00:00
p: 0,
minWidth: "20px",
2023-10-19 10:34:48 +00:00
width: "20px",
}}
>
<Plus />
2023-10-23 15:21:34 +00:00
</Button>
2023-10-19 10:34:48 +00:00
</Box>
);
}