2025-08-06 12:03:48 -07:00
|
|
|
import { useSlotRecipe, chakra, Flex, CloseButton, Text, IconButton } from "@chakra-ui/react"
|
2026-06-04 15:30:01 -07:00
|
|
|
import { Undo } from 'lucide-react';
|
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;
|
2026-06-04 15:30:01 -07:00
|
|
|
|
2025-07-22 11:58:10 -07:00
|
|
|
const recipe = useSlotRecipe({ key: "widget" });
|
|
|
|
|
const styles = recipe();
|
|
|
|
|
|
|
|
|
|
return (
|
2026-06-05 11:13:10 -07:00
|
|
|
<Flex flexDirection="column" w="100%" h="auto">
|
|
|
|
|
{/* HEADER */}
|
|
|
|
|
<Flex css={styles.header} cursor={isEditable ? "move":"default"} flexDirection="row" w="100%" h="auto" justifyContent="space-between" alignItems="center">
|
|
|
|
|
<Text className="widget-handle" w="100%" display="flex" alignItems="center" height="32px" fontWeight="bold">{title}</Text>
|
|
|
|
|
{isDelete ? (
|
|
|
|
|
<CloseButton onClick={() => DeleteWidget(id)} size="xs" _hover={{bg: "tomato", color: "white"}}/>
|
|
|
|
|
):(
|
|
|
|
|
isSubmit ? (
|
|
|
|
|
<IconButton onClick={() => setIsSubmit(false)} size="xs" bg="base300" cursor="pointer"><Undo fill="text" /></IconButton>
|
|
|
|
|
):null
|
|
|
|
|
)}
|
|
|
|
|
</Flex>
|
|
|
|
|
|
|
|
|
|
{/* CHILDREN */}
|
|
|
|
|
<Flex w="100%" h="auto">
|
2025-08-04 12:04:33 -07:00
|
|
|
{children}
|
2026-06-04 15:30:01 -07:00
|
|
|
</Flex>
|
2026-06-05 11:13:10 -07:00
|
|
|
</Flex>
|
2025-07-22 11:58:10 -07:00
|
|
|
);
|
|
|
|
|
}
|
2025-07-21 13:01:16 -07:00
|
|
|
|