2025-08-06 12:03:48 -07:00
|
|
|
import { useSlotRecipe, chakra, Flex, CloseButton, Text, IconButton } from "@chakra-ui/react"
|
2025-08-06 16:27:08 -07:00
|
|
|
import { GrUndo } from "react-icons/gr";
|
2025-07-22 11:58:10 -07:00
|
|
|
|
2025-08-06 16:27:08 -07:00
|
|
|
export default function Widget(props) {
|
|
|
|
|
// deconstructing props
|
|
|
|
|
const { id, title, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit, children } = props;
|
2025-07-22 11:58:10 -07:00
|
|
|
const recipe = useSlotRecipe({ key: "widget" });
|
|
|
|
|
const styles = recipe();
|
|
|
|
|
|
2025-08-06 16:27:08 -07:00
|
|
|
|
2025-07-22 11:58:10 -07:00
|
|
|
return (
|
2025-07-23 13:44:24 -07:00
|
|
|
<>
|
2025-07-28 12:44:17 -07:00
|
|
|
<chakra.div css={styles.header} cursor={isEditable ? "move":"default"}>
|
|
|
|
|
{isDelete ? (
|
|
|
|
|
<>
|
|
|
|
|
<Flex flexDirection="row" justifyContent="space-between" alignItems="center">
|
2025-07-29 11:08:36 -07:00
|
|
|
<Text className="widget-handle" w="100%" fontWeight="bold">{title}</Text>
|
2025-07-28 12:44:17 -07:00
|
|
|
<CloseButton onClick={() => DeleteWidget(id)} size="xs" _hover={{bg: "tomato", color: "white"}}/>
|
|
|
|
|
</Flex>
|
|
|
|
|
</>
|
|
|
|
|
):(
|
|
|
|
|
<>
|
2025-08-06 12:03:48 -07:00
|
|
|
<Flex flexDirection="row" justifyContent="space-between" alignItems="center">
|
|
|
|
|
<Text className="widget-handle" w="100%" display="flex" alignItems="center" height="32px" fontWeight="bold">{title}</Text>
|
2025-08-06 16:27:08 -07:00
|
|
|
{isSubmit ? (
|
|
|
|
|
<IconButton onClick={() => setIsSubmit(false)} size="xs" bg="base300" cursor="pointer"><GrUndo fill="text" /></IconButton>
|
|
|
|
|
):(null)}
|
2025-08-06 12:03:48 -07:00
|
|
|
</Flex>
|
2025-07-28 12:44:17 -07:00
|
|
|
</>
|
|
|
|
|
)}
|
2025-07-22 11:58:10 -07:00
|
|
|
</chakra.div>
|
2025-08-06 16:27:08 -07:00
|
|
|
<chakra.div height="100%" mb="2">
|
2025-08-04 12:04:33 -07:00
|
|
|
{children}
|
2025-07-22 11:58:10 -07:00
|
|
|
</chakra.div>
|
2025-07-23 13:44:24 -07:00
|
|
|
</>
|
2025-07-22 11:58:10 -07:00
|
|
|
);
|
|
|
|
|
}
|
2025-07-21 13:01:16 -07:00
|
|
|
|