import React from "react" import { Center, Text } from "@chakra-ui/react" export const ReactiveRightNav = (props) => { const setNav = React.useCallback((active) => { setMr(active ? "0%" : "-100%") setNavActive(active) }, []) const [entered, setEntered] = React.useState(false) React.useEffect(() => { // react to mouse move event const listener = (event) => { const windowWidth = window.innerWidth if (!entered) { if (event?.clientX >= windowWidth - 60) { setNav(true) } else if (event?.clientX <= windowWidth - 100) { setNav(false) } } } window.addEventListener("mousemove", listener) return () => { window.removeEventListener("mousemove", listener) } }, [setNav, entered]) const [navActive, setNavActive] = React.useState(false) // const defaultMr = '-100%' const defaultMr = "0%" const [mr, setMr] = React.useState(defaultMr) const navItems = React.useMemo(() => { return ["home", "imagine", "create", "share"] }, []) return (
setEntered(true)} onMouseLeave={() => setEntered(false)} paddingX={100} paddingY={80} > {navItems.map((navItem, idx) => { return ( {navItem} ) })}
) }