diff --git a/client/src/components/layout/Canvas/components/Tooltip.jsx b/client/src/components/layout/Canvas/components/Tooltip.jsx new file mode 100644 index 0000000..e073082 --- /dev/null +++ b/client/src/components/layout/Canvas/components/Tooltip.jsx @@ -0,0 +1,45 @@ +import { useState, useRef } from "react"; +import { chakra, useSlotRecipe } from "@chakra-ui/react"; + + +export default function Tooltip ({tooltipkey, content, sidebarIsOpen, children}) { + const [isVisible, setIsVisible] = useState(!sidebarIsOpen); + const recipe = useSlotRecipe({ key: "sidebar" }); + const styles = recipe(); + const timeoutId = useRef(null); + + return ( + { timeoutId.current = setTimeout(() => setIsVisible(true), 1000); }} + onMouseLeave={() => { + if (timeoutId.current) { + clearTimeout(timeoutId.current); + timeoutId.current = null; + } + setIsVisible(false); + }} + > + {children} + {isVisible && !sidebarIsOpen && ( + <> + + {content} + + + )} + + ) +} \ No newline at end of file diff --git a/client/src/components/layout/Canvas/components/Widget.jsx b/client/src/components/layout/Canvas/components/Widget.jsx index 0f6e9ea..314924f 100644 --- a/client/src/components/layout/Canvas/components/Widget.jsx +++ b/client/src/components/layout/Canvas/components/Widget.jsx @@ -12,13 +12,13 @@ export default function Widget({ id, title, isEditable, isDelete, DeleteWidget } {isDelete ? ( <> - {title} + {title} DeleteWidget(id)} size="xs" _hover={{bg: "tomato", color: "white"}}/> ):( <> - {title} + {title} )} diff --git a/client/src/components/layout/Canvas/views/DashboardCanvas.jsx b/client/src/components/layout/Canvas/views/DashboardCanvas.jsx index 8678a50..1773555 100644 --- a/client/src/components/layout/Canvas/views/DashboardCanvas.jsx +++ b/client/src/components/layout/Canvas/views/DashboardCanvas.jsx @@ -81,7 +81,7 @@ export function DashboardCanvas({ layout, setLayout, onLayoutChange }) { return ( /* HEADER */ - + - + My Dashboard - + Gas - + Seismic - + Remote Sensing - + Daily Activity diff --git a/client/src/components/layout/Sidebar/Sidebar.jsx b/client/src/components/layout/Sidebar/Sidebar.jsx index 1db12b9..d78d689 100644 --- a/client/src/components/layout/Sidebar/Sidebar.jsx +++ b/client/src/components/layout/Sidebar/Sidebar.jsx @@ -1,6 +1,7 @@ import { useSlotRecipe, Box, Button, IconButton } from "@chakra-ui/react"; import { ColorModeButton } from "@/components/ui/color-mode"; -import { Tooltip } from "@/components/ui/tooltip"; +// import { Tooltip } from "@/components/ui/tooltip"; +import Tooltip from "../Canvas/components/Tooltip.jsx"; import { FaVolcano } from "react-icons/fa6"; import { FaHome } from "react-icons/fa"; import { FaGlobeAmericas } from "react-icons/fa"; @@ -12,6 +13,8 @@ import { useState } from "react"; export default function Sidebar({ onChangeView }) { const [isOpen, setIsOpen] = useState(true); const [activeButton, setActiveButton] = useState(0) + const recipe = useSlotRecipe({ key: "sidebar" }); + const styles = recipe(); // this list of btns will come from the db (not every usr will have access to admin) const buttons = [ @@ -21,9 +24,6 @@ export default function Sidebar({ onChangeView }) { {icon: FaVolcano, name: "Volcano", view: "volcano"}, {icon: HiUsers, name: "Admin", view: "admin"} ]; - - const recipe = useSlotRecipe({ key: "sidebar" }); - const styles = recipe(); const toggleSidebar = () => { if (isOpen) setIsOpen(false); @@ -35,6 +35,7 @@ export default function Sidebar({ onChangeView }) { css={styles.root} width={isOpen ? "210px" : "71px"} transition="width 0.4s ease" + position="relative" > { const Icon = button.icon; - const buttonElement = ( - - ); - // console.log("buttonElement is:", buttonElement) - console.log("Returning:", !isOpen ? "Tooltip" : "Button", buttonElement); - return !isOpen ? ( - - { buttonElement } + - ) : ( - buttonElement - ); + ) })}