Skip to content

Commit

Permalink
Merge pull request #18 from the-collab-lab/ar-mp-nav-to-all
Browse files Browse the repository at this point in the history
added route handling and added activestatus using navlink
  • Loading branch information
mentalcaries authored Aug 17, 2024
2 parents db241e7 + be4c03f commit 02f3ffe
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/views/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Outlet } from 'react-router-dom';
import { NavLink } from 'react-router-dom';

import './Layout.css';
import { useAuth, SignInButton, SignOutButton } from '../api';
Expand All @@ -11,8 +12,16 @@ import { useAuth, SignInButton, SignOutButton } from '../api';
* defined in `App.jsx`.
*/

const handleActive = ({ isActive, isPending }) => {
return {
fontWeight: isActive ? 'bold' : '',
color: isPending ? 'red' : 'black',
};
};

export function Layout() {
const { user } = useAuth();

return (
<>
<div className="Layout">
Expand All @@ -21,20 +30,21 @@ export function Layout() {
</header>
<main className="Layout-main">
{user ? <SignOutButton /> : <SignInButton />}

<Outlet />
</main>
<nav className="Nav">
<div className="Nav-container">
<a href="#" className="Nav-link">
<NavLink to="/" style={handleActive}>
Home
</a>
<a href="#" className="Nav-link">
</NavLink>

<NavLink to="/list" style={handleActive}>
List
</a>
<a href="#" className="Nav-link">
</NavLink>

<NavLink to="/manage-list" style={handleActive}>
Manage List
</a>
</NavLink>
</div>
</nav>
</div>
Expand Down

0 comments on commit 02f3ffe

Please sign in to comment.