Skip to content

Commit

Permalink
don't hide navbar if it's homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1618 committed Dec 14, 2024
1 parent b2f9d69 commit 277214e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
28 changes: 23 additions & 5 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import MenuIcon from '@mui/icons-material/Menu';
import CloseIcon from '@mui/icons-material/Close';
import { SwipeableDrawer } from '@mui/material';

const links = [
interface LinkMetadata {
name: string;
href: string;
}

const links: LinkMetadata[] = [
{ name: 'Home', href: '/' },
{ name: 'About', href: '/#about' },
{ name: 'Impact', href: '/#impact' },
Expand All @@ -27,10 +32,13 @@ export default function Navbar() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const lastUpdate = useRef(0);

const onLinkClick = () => {
const onLinkClick = (link: LinkMetadata) => {
lastUpdate.current = Date.now();
setVisible(false);
setMobileMenuOpen(false);

if (link.name !== 'Home') {
setVisible(false);
}
};

useEffect(() => {
Expand Down Expand Up @@ -82,7 +90,12 @@ export default function Navbar() {
</div>
<Typography variant="body/large" className={styles.desktopLinks}>
{links.map(link => (
<Link href={link.href} className={styles.link} onClick={onLinkClick} key={link.name}>
<Link
href={link.href}
className={styles.link}
onClick={() => onLinkClick(link)}
key={link.name}
>
{link.name}
</Link>
))}
Expand All @@ -104,7 +117,12 @@ export default function Navbar() {
>
<div className={styles.mobileMenu}>
{links.map(link => (
<Link href={link.href} className={styles.link} onClick={onLinkClick} key={link.name}>
<Link
href={link.href}
className={styles.link}
onClick={() => onLinkClick(link)}
key={link.name}
>
{link.name}
</Link>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/sections/Hero/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
grid-template-columns: auto 1fr;
align-items: flex-start;
padding: 0 vars.$side-padding;
margin: 0 calc(vars.$side-padding * -1);
margin: 8rem calc(vars.$side-padding * -1);
overflow: hidden;
margin-bottom: -35rem;

@media screen and (max-width: vars.$breakpoint-md) {
padding: 0 vars.$side-padding-mobile;
margin: 0 calc(vars.$side-padding-mobile * -1);
margin: 6rem calc(vars.$side-padding-mobile * -1);
}

.text {
Expand Down
2 changes: 0 additions & 2 deletions src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ html {

body {
padding: 0 vars.$side-padding;
margin-top: 8rem;

@media screen and (max-width: vars.$breakpoint-md) {
padding: 0 vars.$side-padding-mobile;
margin-top: 6rem;
}
}

Expand Down

0 comments on commit 277214e

Please sign in to comment.