diff --git a/src/components/Container.tsx b/src/components/Container.tsx index b3988e5..8bf27ea 100644 --- a/src/components/Container.tsx +++ b/src/components/Container.tsx @@ -8,16 +8,6 @@ import { getTimeout } from "../util"; import Menu from "./Menu"; import useMediaQuery from "../util/useMediaQuery"; -const flash = css` - span& { - width: 5.6rem; - height: 5.6rem; - top: -0.2rem; - left: -0.05rem; - opacity: 1; - } -`; - const [timer, clear] = getTimeout(); const Container: React.FunctionComponent<{ @@ -39,7 +29,6 @@ const Container: React.FunctionComponent<{ const mobile = useMediaQuery("(max-width: 50rem)"); const logoContainer = useRef(null); - const logo = useRef(null); const highlightCircle = useRef(null); const containerChild = useRef(null); const nextBtn = useRef(null); @@ -61,8 +50,11 @@ const Container: React.FunctionComponent<{ window.scrollTo({ top: 0 }); if (highlightCircle.current) { - highlightCircle.current.classList.add(flash); - timer(() => highlightCircle.current && highlightCircle.current.classList.remove(flash), 1500); + highlightCircle.current.classList.add("highlight"); + timer( + () => highlightCircle.current && highlightCircle.current.classList.remove("highlight"), + 1500, + ); } if (nextBtn.current) { @@ -139,15 +131,6 @@ const Container: React.FunctionComponent<{ background: none; border: 0; font-size: 1rem; - - &:hover .logo-highlight, - &:active .logo-highlight { - width: 5.2rem; - height: 5.2rem; - opacity: 1; - top: -0.05rem; - left: 0.15rem; - } `} onMouseOver={() => !mobile && setShowMenu(true)} onMouseOut={() => !mobile && setShowMenu(false)}> @@ -156,31 +139,61 @@ const Container: React.FunctionComponent<{ className={cx( css` position: absolute; - width: 5rem; + left: 0; height: 5rem; + width: 5rem; border-radius: 100%; - background: var(--primary-colour); - z-index: 0; - opacity: 0; + box-shadow: 0px 0px 50px 0px rgba(100, 100, 100, 0.65); cursor: pointer; - transition: all 600ms; + & > svg { + width: 100%; + height: 100%; + position: absolute; + inset: 0; + z-index: 1; + } + + &::before { + content: ""; + position: absolute; + left: -0.1rem; + width: 5rem; + height: 5rem; + border-radius: 100%; + background: var(--primary-colour); + z-index: 0; + opacity: 0; + cursor: pointer; + + transition: all 600ms; + } + + &:hover::before, + &.highlight::before { + opacity: 1; + } + + &:hover::before { + width: 5.2rem; + height: 5.2rem; + top: -0.05rem; + left: -0.1rem; + } + + &.highlight::before { + width: 5.6rem; + height: 5.6rem; + top: -0.3rem; + left: -0.3rem; + } `, - "logo-highlight", - )}> - (mobile ? setShowMenu(true) : history.push("/"))} - /> + )}> + (mobile ? setShowMenu(true) : history.push("/"))} + /> + )} diff --git a/src/components/Menu.tsx b/src/components/Menu.tsx index 679ae39..a3dab31 100644 --- a/src/components/Menu.tsx +++ b/src/components/Menu.tsx @@ -65,7 +65,9 @@ const Menu: React.FunctionComponent<{ show?: boolean; setShowMenu: (show: boolea show = false, setShowMenu, }) => { + // use same query as elsewhere for consistency const mobile = useMediaQuery("(max-width: 50rem)"); + const notmobile = !mobile; const menuItems = menu.map(item => ( @@ -73,20 +75,21 @@ const Menu: React.FunctionComponent<{ show?: boolean; setShowMenu: (show: boolea )); - // TODO(mkr): refactor return ( -
    + className={notmobile ? desktopNav : offscreenNav} + animate={{ + // if resized to mobile and back, numeric value will persist but + // will be ignored because desktopNav isn't absolutely positioned + top: notmobile ? "auto" : show ? "0" : "-100%", + // only children need to animate on desktop, lock opacity: 1 + opacity: notmobile ? 1 : show ? 1 : 0, + }}> +
      - {mobile - ? menuItems.concat( + {notmobile + ? menuItems + : menuItems.concat(
      , - ) - : menuItems} + )}