-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented individual routes per nav item
replaced Router by HashRouter
- Loading branch information
1 parent
bb5160e
commit ff07835
Showing
5 changed files
with
118 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from "react"; | ||
import { useHistory, useLocation } from "react-router-dom"; | ||
import { Nav, NavItem, NavList } from "@patternfly/react-core"; | ||
import * as _ from "lodash"; | ||
import "./navBar.css"; | ||
|
||
const Navigation: React.FunctionComponent = () => { | ||
const history = useHistory(); | ||
const location = useLocation(); | ||
const [activeItem, setActiveItem] = React.useState<string>("workloads"); | ||
const routes = ["workloads", "storage", "compute", "results"]; | ||
|
||
const onSelect = React.useCallback( | ||
(result: { itemId: string | number }) => { | ||
setActiveItem(result.itemId as string); | ||
history.push(`/${result.itemId}`); | ||
}, | ||
[history] | ||
); | ||
|
||
React.useEffect(() => { | ||
const pathname = location?.pathname?.replace?.("/", ""); | ||
if (!pathname) return; | ||
setActiveItem(pathname); | ||
}, [location]); | ||
|
||
return ( | ||
<Nav onSelect={onSelect} variant="horizontal" aria-label="Navigation bar"> | ||
<NavList> | ||
{routes.map((route: string) => ( | ||
<NavItem | ||
id={`nav-item-${route}`} | ||
key={route} | ||
preventDefault | ||
itemId={route} | ||
isActive={activeItem === route} | ||
> | ||
{_.capitalize(route)} | ||
</NavItem> | ||
))} | ||
</NavList> | ||
</Nav> | ||
); | ||
}; | ||
|
||
export default Navigation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./Navbar"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.pf-c-nav.pf-m-horizontal { | ||
background-color: var(--pf-global--Color--light-100); | ||
padding-left: 1.75rem; | ||
--pf-c-nav__link--FontSize: 1.4rem; | ||
--pf-c-nav__link--FontWeight: var( | ||
--pf-global--FontWeight--overpass--semi-bold | ||
); | ||
border-bottom: var(--pf-global--BorderWidth--sm) solid | ||
var(--pf-global--palette--black-300); | ||
} | ||
|
||
.pf-c-nav__link { | ||
--pf-c-nav__link--Color: var(--pf-global--palette--black-600); | ||
--pf-c-nav__link--PaddingTop: var(--pf-global--spacer--sm); | ||
--pf-c-nav__link--PaddingRight: var(--pf-global--spacer--md); | ||
--pf-c-nav__link--PaddingBottom: var(--pf-global--spacer--sm); | ||
--pf-c-nav__link--PaddingLeft: var(--pf-global--spacer--md); | ||
--pf-c-nav__link--m-current--Color: var(--pf-global--palette--blue-400); | ||
} | ||
|
||
.pf-c-nav__link:active { | ||
--pf-c-nav__link--active--Color: var(--pf-global--palette--black-600); | ||
} | ||
|
||
.pf-c-nav__link:hover { | ||
--pf-c-nav__link--hover--Color: var(--pf-global--palette--black-600); | ||
} | ||
|
||
.pf-c-nav__link::before { | ||
--pf-c-nav__link--before--BorderColor: currentColor; | ||
--pf-c-nav--m-horizontal__link--Right: 0; | ||
--pf-c-nav--m-horizontal__link--Left: 0; | ||
} | ||
|
||
.pf-c-nav__link:hover::before { | ||
--pf-c-nav__link--before--BorderColor: var(--pf-global--palette--black-300); | ||
} | ||
|
||
.pf-c-nav__link.pf-m-current:hover::before { | ||
--pf-c-nav__link--before--BorderColor: currentColor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters