Skip to content

Commit

Permalink
made background turn grey when scrolled, changed hover animation to w…
Browse files Browse the repository at this point in the history
…hite glow
  • Loading branch information
ofjuneskies committed Nov 1, 2024
1 parent e3aa513 commit 91bad0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
10 changes: 6 additions & 4 deletions apps/site/src/components/NavBar/NavBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
.nav {
width: 100%;
z-index: 101;
background-color: rgba(1, 167, 197, 0.5);
background-color: rgba(20, 20, 20, 0.7);
mix-blend-mode: hard-light;
@include utils.media-breakpoint-up(lg) {
backdrop-filter: none;
}
Expand Down Expand Up @@ -43,7 +44,7 @@
}

&:hover {
text-shadow: -3px -3px 3px #363837;
text-shadow: 0 0 5px white;
}
}

Expand All @@ -64,6 +65,7 @@
background-color: transparent;
}

.bg-ocean {
background-color: rgba(1, 167, 197, 0.5);
.bg-scrolled {
background-color: rgba(20, 20, 20, 0.7);
mix-blend-mode: hard-light;
}
22 changes: 3 additions & 19 deletions apps/site/src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,11 @@ import styles from "./NavBar.module.scss";
export default function NavBar() {
const activeRoute = usePathname();

const [hasScrolledToOcean, setHasScrolledToOcean] = useState(false);
const [hasScrolled, setHasScrolled] = useState(false);

useEffect(() => {
const getScrollThreshold = () => {
if (window.innerWidth < 768) {
// For mobile screens
return document.documentElement.scrollHeight / 7;
} else if (window.innerWidth < 1200) {
// For tablets and small desktops
return document.documentElement.scrollHeight / 4;
} else {
// For large desktops
return document.documentElement.scrollHeight / 2;
}
};

let scrollThreshold = getScrollThreshold();
const handleScroll = () =>
window.scrollY > scrollThreshold
? setHasScrolledToOcean(true)
: setHasScrolledToOcean(false);
window.scrollY !== 0 ? setHasScrolled(true) : setHasScrolled(false);

window.addEventListener("scroll", handleScroll);

Expand All @@ -46,7 +30,7 @@ export default function NavBar() {

return (
<div
className={`${styles.nav} fixed-top ${hasScrolledToOcean ? "bg-ocean" : "bg-transparent"}`}
className={`${styles.nav} fixed-top ${hasScrolled ? "bg-scrolled" : "bg-transparent"}`}
>
<Navbar variant="dark" expand="lg" className={`${styles.navbar}`}>
<Container fluid>
Expand Down

0 comments on commit 91bad0c

Please sign in to comment.