Header+Footer: complete refactor of hover logic :)
This commit is contained in:
@@ -5,6 +5,12 @@ footer {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 1280px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#back-to-top-button {
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useState } from "react";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import React from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import { Heart } from "phosphor-react";
|
||||
|
||||
import uArrowUpLeft from "../../assets/u-arrow-up-left.svg";
|
||||
@@ -18,11 +18,9 @@ const variants = {
|
||||
};
|
||||
|
||||
const Footer: React.FC<FooterProps> = () => {
|
||||
const [hovered, setHovered] = useState<string | false>(false);
|
||||
const clearHover = () => setHovered(false);
|
||||
|
||||
return (
|
||||
<footer>
|
||||
<div className="container">
|
||||
<div className="outro">
|
||||
<h2>
|
||||
Phosphor is free and open source software. If you enjoy these icons,
|
||||
@@ -91,68 +89,34 @@ const Footer: React.FC<FooterProps> = () => {
|
||||
<img src={uArrowUpLeft} alt="" />
|
||||
</button>
|
||||
</div>
|
||||
<AnimatePresence>
|
||||
{hovered === "phone" ? (
|
||||
<img id="phone" className="inspectable" src={phoneSpec} alt="" />
|
||||
<motion.img
|
||||
id="phone"
|
||||
key="phone-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={variants}
|
||||
// onHoverStart={() => setHovered("phone")}
|
||||
onHoverEnd={clearHover}
|
||||
src={phoneSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="phone"
|
||||
key="phone"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={variants}
|
||||
onHoverStart={() => setHovered("phone")}
|
||||
// onHoverEnd={clearHover}
|
||||
initial="visible"
|
||||
whileHover="hidden"
|
||||
src={phone}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
{hovered === "command" ? (
|
||||
<motion.img
|
||||
<img
|
||||
id="command"
|
||||
key="command-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={variants}
|
||||
// onHoverStart={() => setHovered("command")}
|
||||
onHoverEnd={clearHover}
|
||||
src={commandKeySpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="command"
|
||||
key="command"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={variants}
|
||||
onHoverStart={() => setHovered("command")}
|
||||
// onHoverEnd={clearHover}
|
||||
initial="visible"
|
||||
whileHover="hidden"
|
||||
src={commandKey}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<img id="marker-green" src={markerGreen} alt="" />
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ a.nav-link:hover:after {
|
||||
|
||||
#calculator {
|
||||
position: absolute;
|
||||
transform: translate(800px, 240px);
|
||||
transform: translate(800px, 112px);
|
||||
}
|
||||
|
||||
/* Illustrations remain at same layout up to 1024px */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useState } from "react";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import React from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import { ArrowUpRightCircle, ArrowDownCircle } from "phosphor-react";
|
||||
|
||||
import "./Header.css";
|
||||
@@ -40,9 +40,6 @@ const handleScrollToIcons = () => {
|
||||
};
|
||||
|
||||
const Header: React.FC<HeaderProps> = () => {
|
||||
const [hovered, setHovered] = useState<string | false>(false);
|
||||
const clearHover = () => setHovered(false);
|
||||
|
||||
return (
|
||||
<header>
|
||||
<motion.div
|
||||
@@ -89,181 +86,83 @@ const Header: React.FC<HeaderProps> = () => {
|
||||
Github
|
||||
</a>
|
||||
</div>
|
||||
{hovered === "cutting-mat" ? (
|
||||
<motion.img
|
||||
<img
|
||||
id="cutting-mat"
|
||||
key="cutting-mat-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("cutting-mat")}
|
||||
onHoverEnd={clearHover}
|
||||
src={cuttingMatSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="cutting-mat"
|
||||
key="cutting-mat"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("cutting-mat")}
|
||||
// onHoverEnd={clearHover}
|
||||
initial="visible"
|
||||
whileHover="hidden"
|
||||
src={cuttingMat}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
{hovered === "receipt" ? (
|
||||
<img id="receipt" className="inspectable" src={receiptSpec} alt="" />
|
||||
<motion.img
|
||||
id="receipt"
|
||||
key="receipt-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("receipt")}
|
||||
onHoverEnd={clearHover}
|
||||
src={receiptSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="receipt"
|
||||
key="receipt"
|
||||
className="inspectable"
|
||||
initial="visible"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("receipt")}
|
||||
// onHoverEnd={clearHover}
|
||||
whileHover="hidden"
|
||||
src={receipt}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
{hovered === "calculator" ? (
|
||||
<motion.img
|
||||
<img
|
||||
id="calculator"
|
||||
key="calculator-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("calculator")}
|
||||
onHoverEnd={clearHover}
|
||||
src={calculatorSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="calculator"
|
||||
key="calculator"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("calculator")}
|
||||
// onHoverEnd={clearHover}
|
||||
initial="hidden"
|
||||
whileHover="hidden"
|
||||
src={calculator}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<AnimatePresence>
|
||||
{hovered === "tablet" ? (
|
||||
<img id="tablet" className="inspectable" src={tabletSpec} alt="" />
|
||||
<motion.img
|
||||
id="tablet"
|
||||
key="tablet-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("tablet")}
|
||||
onHoverEnd={clearHover}
|
||||
src={tabletSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="tablet"
|
||||
key="tablet"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("tablet")}
|
||||
// onHoverEnd={clearHover}
|
||||
whileHover="hidden"
|
||||
src={tablet}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
{hovered === "billiard-ball" ? (
|
||||
<motion.img
|
||||
<img
|
||||
id="billiard-ball"
|
||||
key="billiard-ball-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("billiard-ball")}
|
||||
onHoverEnd={clearHover}
|
||||
src={billiardBallSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="billiard-ball"
|
||||
key="billiard-ball"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("billiard-ball")}
|
||||
// onHoverEnd={clearHover}
|
||||
initial="hidden"
|
||||
whileHover="hidden"
|
||||
src={billiardBall}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
{hovered === "warning" ? (
|
||||
|
||||
<img id="warning" className="inspectable" src={warningSpec} alt="" />
|
||||
<motion.img
|
||||
id="warning"
|
||||
key="warning-spec"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
// onHoverStart={() => setHovered("warning")}
|
||||
onHoverEnd={clearHover}
|
||||
src={warningSpec}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
id="warning"
|
||||
key="warning"
|
||||
className="inspectable"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
variants={illustrationVariants}
|
||||
onHoverStart={() => setHovered("warning")}
|
||||
// onHoverEnd={clearHover}
|
||||
whileHover="hidden"
|
||||
src={warning}
|
||||
alt=""
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</motion.div>
|
||||
</header>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user