Extracted nav pills to their own component for reusability

This commit is contained in:
Alejandro Celaya
2022-02-13 20:20:20 +01:00
parent cf5205e976
commit b0fa14fcfe
6 changed files with 54 additions and 45 deletions

30
src/utils/NavPills.scss Normal file
View File

@@ -0,0 +1,30 @@
@import './base';
.nav-pills__nav {
position: sticky !important;
top: $headerHeight - 1px;
z-index: 2;
}
.nav-pills__nav-link {
border-radius: 0 !important;
padding-bottom: calc(.5rem - 3px) !important;
border-bottom: 3px solid transparent;
color: #5d6778;
font-weight: 700;
cursor: pointer;
@media (min-width: $smMin) and (max-width: $mdMax) {
font-size: 89%;
}
}
.nav-pills__nav-link:hover {
color: $mainColor !important;
}
.nav-pills__nav-link.active {
border-color: $mainColor;
background-color: var(--primary-color) !important;
color: $mainColor !important;
}

17
src/utils/NavPills.tsx Normal file
View File

@@ -0,0 +1,17 @@
import { FC, ReactNode } from 'react';
import { Card, Nav, NavLink } from 'reactstrap';
import { NavLink as RouterNavLink } from 'react-router-dom';
import './NavPills.scss';
interface NavPillsProps {
items: { children: ReactNode; to: string; replace?: boolean }[];
}
export const NavPills: FC<NavPillsProps> = ({ items }) => (
<Card className="nav-pills__nav p-0 overflow-hidden mb-3" body>
<Nav pills fill>
{items.map(({ children, ...rest }, index) =>
<NavLink key={index} className="nav-pills__nav-link" tag={RouterNavLink} {...rest}>{children}</NavLink>)}
</Nav>
</Card>
);