Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 20x 20x 20x 20x 20x 45x 45x | import { Box, Stack } from "@mui/material";
import { PlusIcon, XIcon } from "@phosphor-icons/react";
import React, { useState } from "react";
import { MediaItem } from "../provider/provider.type";
import { styled } from "@theme/v2/Provider";
import { isEmpty } from "lodash";
import ImageModalNew from "@sections/PayBuilder/Forms/About/ImageModalNew";
interface Props {
imageUrl?: string;
handleSelect: (item?: MediaItem | any) => void;
height?: string;
width?: string;
filterPNGOnly?: boolean;
}
function ImageBox({
imageUrl,
handleSelect,
height = "120px",
width = "120px",
filterPNGOnly,
}: Props) {
const [isImageModalOpen, setIsImageModalOpen] = useState(false);
const onClose = () => setIsImageModalOpen(false);
const onSelect = (item?: MediaItem) => {
handleSelect(isEmpty(item) ? {} : item);
onClose();
};
const handleOpen = () => setIsImageModalOpen(true);
return (
<>
{imageUrl ? (
<Box
height={height}
width={width}
onClick={handleOpen}
position="relative"
>
<Box
borderRadius="8px"
component="img"
width="100%"
height="100%"
sx={{ objectFit: "contain" }}
src={imageUrl + "/original"}
/>
<CancelButton
onClick={(E) => {
E.stopPropagation();
onSelect();
}}
>
<XIcon size="15px" />
</CancelButton>
</Box>
) : (
<EmptyImageContainer height={height} width={width} onClick={handleOpen}>
<PlusIcon />
</EmptyImageContainer>
)}
<ImageModalNew
handleSelect={onSelect}
open={isImageModalOpen}
onClose={onClose}
selectedImage={{ URL: imageUrl } as MediaItem}
noEditing
/>
</>
);
}
export default ImageBox;
const CancelButton = styled(Stack)(({ theme }) => ({
cursor: "pointer",
backgroundColor: theme.palette.surface?.primary,
borderRadius: "50%",
position: "absolute",
top: 2,
right: 2,
height: "24px",
width: "24px",
justifyContent: "center",
alignItems: "center",
}));
const EmptyImageContainer = styled(Stack)(({ theme }) => ({
backgroundColor: theme.palette.primitive?.transparent["darken-5"],
borderRadius: "8px",
justifyContent: "center",
alignItems: "center",
}));
|