Skip to content

Commit

Permalink
Updated Navlink
Browse files Browse the repository at this point in the history
  • Loading branch information
ianvexler committed Feb 15, 2024
1 parent 9991ea9 commit 38e811a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
24 changes: 4 additions & 20 deletions example/components/MainNav.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
import { NavLink } from 'react-router-dom';
import Nav from 'react-bootstrap/Nav';
import { NavItem, NavContext } from '@the-curve-consulting/texmo-react-components';

export interface NavItemProps {
route: string;
label: string;
icon: string;
}

const NavItem = ({ route, label, icon }: NavItemProps) => {
const linkClass = (isActive: boolean): string => {
return isActive ? 'nav-link active' : 'nav-link link-dark';
};

return (
<Nav.Item>
<NavLink to={route} className={({ isActive }) => linkClass(isActive)}>
<i className={`bi bi-${icon} d-block`} />
{label}
</NavLink>
<hr />
</Nav.Item>
);
};

const Navbar = () => {
return (
<>
<NavItem
<NavContext.Provider value={NavLink}>
<NavItem
route={'/'}
icon={'house'}
label={'Home'}
Expand All @@ -41,7 +25,7 @@ const Navbar = () => {
icon={'list-task'}
label={'List'}
/>
</>
</NavContext.Provider>
)
}

Expand Down
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38e811a

Please sign in to comment.