-
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.
fix: subheader active link changes depending on the route
- Loading branch information
1 parent
88f8dc8
commit eef241f
Showing
5 changed files
with
128 additions
and
96 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 |
---|---|---|
@@ -1,92 +1,101 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
const Subheader = () => ( | ||
<div> | ||
<nav className="navigation-main" id="navbar"> | ||
<div className="container"> | ||
<ul> | ||
<li className="active"> | ||
<Link | ||
href={{ | ||
pathname: '/reporter' | ||
}} | ||
> | ||
<a>My Dashboard</a> | ||
</Link> | ||
</li> | ||
<li> | ||
<Link | ||
href={{ | ||
pathname: '/reporter/facilities' | ||
}} | ||
> | ||
<a>My Applications</a> | ||
</Link> | ||
</li> | ||
</ul> | ||
</div> | ||
<style jsx>{` | ||
.navigation-main { | ||
color: #fcba19; | ||
background-color: #38598a; | ||
width: 100%; | ||
-webkit-box-shadow: 0 6px 8px -4px #b3b1b3; | ||
-moz-box-shadow: 0 6px 8px -4px #b3b1b3; | ||
box-shadow: 0 6px 8px -4px #b3b1b3; | ||
padding: 10px 0 10px 50px; | ||
} | ||
.navigation-main ul { | ||
display: flex; | ||
flex-direction: row; | ||
margin: 0; | ||
color: #fff; | ||
list-style: none; | ||
margin-left: -75px; | ||
} | ||
.navigation-main ul li a { | ||
display: flex; | ||
font-size: 17px; | ||
font-weight: normal; /* 400 */ | ||
color: #fff !important; | ||
padding: 0 15px 0 15px; | ||
text-decoration: none; | ||
} | ||
.navigation-main ul li a:hover { | ||
text-decoration: underline; | ||
} | ||
.navigation-main ul .active { | ||
text-decoration: underline; | ||
font-weight: bold; | ||
} | ||
.navigation-main ul > li.active a { | ||
color: #ffc107 !important; | ||
} | ||
import {useRouter} from 'next/router'; | ||
|
||
:focus { | ||
outline: 4px solid #3b99fc; | ||
outline-offset: 1px; | ||
} | ||
const DASHBOARD_PATH = '/reporter'; | ||
const APPLICATIONS_PATH = '/reporter/facilities'; | ||
|
||
@media screen and (min-width: 768px) { | ||
const Subheader = () => { | ||
const {asPath} = useRouter(); | ||
|
||
return ( | ||
<div> | ||
<nav className="navigation-main" id="navbar"> | ||
<div className="container"> | ||
<ul> | ||
<li className={asPath === DASHBOARD_PATH ? 'active' : ''}> | ||
<Link | ||
href={{ | ||
pathname: DASHBOARD_PATH | ||
}} | ||
> | ||
<a>My Dashboard</a> | ||
</Link> | ||
</li> | ||
<li className={asPath === APPLICATIONS_PATH ? 'active' : ''}> | ||
<Link | ||
href={{ | ||
pathname: APPLICATIONS_PATH | ||
}} | ||
> | ||
<a>My Applications</a> | ||
</Link> | ||
</li> | ||
</ul> | ||
</div> | ||
<style jsx>{` | ||
.navigation-main { | ||
display: block; | ||
color: #fcba19; | ||
background-color: #38598a; | ||
width: 100%; | ||
-webkit-box-shadow: 0 6px 8px -4px #b3b1b3; | ||
-moz-box-shadow: 0 6px 8px -4px #b3b1b3; | ||
box-shadow: 0 6px 8px -4px #b3b1b3; | ||
padding: 10px 0 10px 50px; | ||
} | ||
.navigation-main ul { | ||
display: flex; | ||
flex-direction: row; | ||
margin: 0; | ||
color: #fff; | ||
list-style: none; | ||
margin-left: -75px; | ||
} | ||
.navigation-main ul li a { | ||
display: flex; | ||
font-size: 17px; | ||
font-weight: normal; /* 400 */ | ||
color: #fff !important; | ||
padding: 0 15px 0 15px; | ||
text-decoration: none; | ||
} | ||
.navigation-main ul li a:hover { | ||
text-decoration: underline; | ||
} | ||
.navigation-main ul .active { | ||
text-decoration: underline; | ||
font-weight: bold; | ||
} | ||
.navigation-main ul > li.active a { | ||
color: #ffc107 !important; | ||
} | ||
.navigation-main ul li { | ||
margin: 0; | ||
:focus { | ||
outline: 4px solid #3b99fc; | ||
outline-offset: 1px; | ||
} | ||
.navigation-main ul li a { | ||
border-right: 1px solid #9b9b9b; | ||
@media screen and (min-width: 768px) { | ||
.navigation-main { | ||
display: block; | ||
} | ||
.navigation-main ul { | ||
flex-direction: row; | ||
} | ||
.navigation-main ul li { | ||
margin: 0; | ||
} | ||
.navigation-main ul li a { | ||
border-right: 1px solid #9b9b9b; | ||
} | ||
} | ||
} | ||
`}</style> | ||
</nav> | ||
</div> | ||
); | ||
`}</style> | ||
</nav> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Subheader; |
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
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
16 changes: 8 additions & 8 deletions
16
app/tests/unit/components/Layout/__snapshots__/Subheader.test.tsx.snap
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