Files
Web-Frontend/client/src/components/Canvas/CanvasComponents/Widget.jsx
T

34 lines
1.3 KiB
React
Raw Normal View History

2025-08-06 12:03:48 -07:00
import { useSlotRecipe, chakra, Flex, CloseButton, Text, IconButton } from "@chakra-ui/react"
import { FaEllipsisH } from "react-icons/fa";
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-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>
<IconButton size="xs" bg="base300" cursor="pointer"><FaEllipsisH fill="text"/></IconButton>
</Flex>
2025-07-28 12:44:17 -07:00
</>
)}
2025-07-22 11:58:10 -07:00
</chakra.div>
2025-08-06 12:03:48 -07:00
<chakra.div height="100%" mb="3">
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
);
}