Skip to content

Commit

Permalink
remove nav listener on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheaton committed Jun 5, 2024
1 parent 77da569 commit 447bb82
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/ButtonElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const Button = styled(Link)`
border-radius: 50px;
background: ${({ primary }) => (primary ? "#01BF71" : "#010606")};
white-space: nowrap;
padding: ${({ big }) => (big ? " 14px 48px" : "12px 30px")};
padding: ${({ big }) => (big ? "14px 48px" : "12px 30px")};
color: ${({ dark }) => (dark ? "#010106" : "#fff")};
font-size: $ ${({ fontBig }) => (fontBig ? "20px" : "16px")};
outline: none;
Expand Down
3 changes: 1 addition & 2 deletions src/components/HeroSection/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import img from "../../images/F23.prince.learning.turquoise.jpg";
import {
HeroCitationBlock,
Expand Down Expand Up @@ -124,7 +123,7 @@ export default function HeroSection() {
<HeroCitationBlock>
<pre>
<code>
<React.Fragment>{citation}</React.Fragment>
<>{citation}</>
</code>
</pre>
</HeroCitationBlock>
Expand Down
20 changes: 12 additions & 8 deletions src/components/NavBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ import {
export default function NavBar({ toggle }) {
const [scrollNav, setScrollNav] = useState(false);

const changeNav = () => {
if (window.scrollY >= 80) {
setScrollNav(true);
} else {
setScrollNav(false);
}
};

useEffect(() => {
const changeNav = () => {
if (window.scrollY >= 80) {
setScrollNav(true);
} else {
setScrollNav(false);
}
};

window.addEventListener("scroll", changeNav);

return () => {
window.removeEventListener("scroll", changeNav);
};
}, []);

const toggleHome = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Notebooks/NotebookElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const NotebookWrapper = styled.div`
display: grid;
z-index: 1;
/* height: 1250px; */
width: 100% ;
width: 100%;
max-width: 1100px;
margin-right: auto;
margin-left: auto;
Expand Down Expand Up @@ -62,7 +62,7 @@ export const Column2 = styled.p`
`

export const TextWrapper = styled.div`
max-width: 540px ;
max-width: 540px;
padding-top: 0;
padding-bottom: 0;
`
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScrollToTop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function ScrollToTop() {
const { pathname } = useLocation();

useEffect(() => {
window.scrollTo(0, 0, {});
window.scrollTo(0, 0, { behavior: "smooth" });
}, [pathname]);

return null;
Expand Down

0 comments on commit 447bb82

Please sign in to comment.