Close mobile navbar when links are clicked

This commit is contained in:
2024-04-30 20:58:02 +01:00
parent eb05b1f7b5
commit 5cd551d259
3 changed files with 11 additions and 3 deletions

View File

@@ -45,7 +45,11 @@ export default function NavBar() {
<div className="fixed inset-0 z-10" /> <div className="fixed inset-0 z-10" />
<Dialog.Panel className="fixed inset-y-0 right-0 z-10 bg-black w-full overflow-y-auto px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10 text-white sm:border-l-2"> <Dialog.Panel className="fixed inset-y-0 right-0 z-10 bg-black w-full overflow-y-auto px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10 text-white sm:border-l-2">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<Link to="/" className="-m-1.5 p-1.5"> <Link
to="/"
className="-m-1.5 p-1.5"
onClick={() => setMobileMenuOpen(false)}
>
<span className="sr-only">Beau Findlay</span> <span className="sr-only">Beau Findlay</span>
<img className="h-16 w-auto" src={logo} alt="Logo" /> <img className="h-16 w-auto" src={logo} alt="Logo" />
</Link> </Link>
@@ -64,12 +68,14 @@ export default function NavBar() {
<NavLink <NavLink
to="/work" to="/work"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7" className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7"
onClick={() => setMobileMenuOpen(false)}
> >
Work Work
</NavLink> </NavLink>
<NavLink <NavLink
to="/about" to="/about"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7" className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7"
onClick={() => setMobileMenuOpen(false)}
> >
This App This App
</NavLink> </NavLink>

View File

@@ -4,15 +4,17 @@ interface Props {
children: string; children: string;
to: string; to: string;
className?: string | null; className?: string | null;
onClick?: () => void;
} }
export default function NavLink({ children, to, className }: Props) { export default function NavLink({ children, to, className, onClick }: Props) {
const defaultStyles = "text-base font-semibold leading-6 hover:text-gray-300"; const defaultStyles = "text-base font-semibold leading-6 hover:text-gray-300";
const styles = className ? className : defaultStyles; const styles = className ? className : defaultStyles;
return ( return (
<ReactNavLink <ReactNavLink
to={to} to={to}
onClick={onClick}
className={({ isActive }) => className={({ isActive }) =>
isActive ? `${styles} underline underline-offset-4` : styles isActive ? `${styles} underline underline-offset-4` : styles
} }

View File

@@ -6,7 +6,7 @@ export default function WorkPage() {
return ( return (
<> <>
<Title className="text-center mb-4">Work</Title> <Title className="text-center mb-4">Work</Title>
<p className="text-center text-2xl font-semibold mb-10"> <p className="text-center text-2xl font-semibold mb-12">
Freelance Software Engineer since 2018 Freelance Software Engineer since 2018
</p> </p>
<WorkTimeline /> <WorkTimeline />