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