2025-07-28 12:44:17 -07:00
|
|
|
import { useSlotRecipe, chakra, Flex, CloseButton, Text } from "@chakra-ui/react"
|
2025-07-22 11:58:10 -07:00
|
|
|
|
2025-08-04 12:04:33 -07:00
|
|
|
export default function Widget({ id, title, isEditable, isDelete, DeleteWidget, children }) {
|
2025-07-22 11:58:10 -07:00
|
|
|
const recipe = useSlotRecipe({ key: "widget" });
|
|
|
|
|
const styles = recipe();
|
|
|
|
|
|
|
|
|
|
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-05 17:12:59 -07:00
|
|
|
<Text display="flex" alignItems="center" height="32px" className="widget-handle" fontWeight="bold">{title}</Text>
|
2025-07-28 12:44:17 -07:00
|
|
|
</>
|
|
|
|
|
)}
|
2025-07-22 11:58:10 -07:00
|
|
|
</chakra.div>
|
2025-08-05 17:12:59 -07:00
|
|
|
<chakra.div height="100%">
|
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
|
|
|
|