Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved responsiveness of navbar #315

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions frontend/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -12,20 +12,22 @@ export class Header extends Component {
constructor(props){
super(props);
this.state = {
navHidden: window.innerWidth <= 640?true:false,
navHidden: false,
}
}

showHideNav = () =>{
this.setState({
navHidden: this.state.navHidden?false:true,
})

this.setState({
navHidden: this.state.navHidden ?false:true,
})

}

hideNav = () =>{
if(window.innerWidth <= 640){
this.setState({
navHidden: true,
navHidden: false,
})
}
}
@@ -45,8 +47,9 @@ export class Header extends Component {
</Link>
</div>
<div className="cell medium-9">
<nav className={style.nav}>
<ul className={style["nav__item-container"]} style={{display: this.state.navHidden?'none':'flex'}}>
<nav className={style.nav} >
<ul className={style["nav__item-container"]} style={{display: this.state.navHidden&&'flex'}}>

<li className={style["nav__item"]} onClick={this.hideNav}>
<NavLink to="/forum" activeClassName="active">
Forum
@@ -90,7 +93,7 @@ export class Header extends Component {
</li>
)}
</ul>
<button id={style["menu-icon"]} aria-label="menu icon" onClick={this.showHideNav}>
<button id={style["menu-icon"]} className={style["mobile-menu"]} aria-label="menu icon" onClick={this.showHideNav}>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
186 changes: 86 additions & 100 deletions frontend/src/components/Header/header.module.scss
Original file line number Diff line number Diff line change
@@ -1,117 +1,103 @@
// importing global from the settings folder
@import "../../css/settings/global";

// Header bar
.header{
height:80px;

.header {
height: 80px;
position: fixed;
top: 0;

background-color:$yellow-bg;
border-bottom:1px solid rgba(171, 29, 121, 0.3);
background-color: $yellow-bg;
border-bottom: 1px solid rgba(171, 29, 121, 0.3);
width: 100%;
z-index: 9999;

&__logo{
height:46px; margin-top:17px;
&__logo {
height: 46px;
margin-top: 17px;
}
}
.nav{
display:flex;
}

.nav {
display: flex;
justify-content: flex-end;

// ul
&__item-container{
display:flex;
margin:0;

// gap not supported on safari
// gap:20px;
&__item-container {
display: flex;
margin: 0;
// gap not supported on safari
// gap:20px;
}

&__item{
@extend .text;
list-style-type: none;
color:$title-color;
line-height:80px;
font-weight: $font-weight-regular;

a:hover,a:focus,.active{
color:$purple;
text-decoration:underline;
}

a[class*='button']:hover{
text-decoration: none;
color:white;
}

// to give gap between the nav items (since gap is not supported by all browsers)
&:not(:last-child){
margin-right:20px;
}
&__item {
@extend .text;
list-style-type: none;
color: $title-color;
line-height: 80px;
font-weight: $font-weight-regular;
a:hover,
a:focus,
.active {
color: $purple;
text-decoration: underline;
}
a[class*='button']:hover {
text-decoration: none;
color: white;
}
// to give gap between the nav items (since gap is not supported by all browsers)
&:not(:last-child) {
margin-right: 20px;
}
}
}
#menu-icon{
display:none
}
@media only screen and (max-width:640px){
.header{
background-color:$yellow-bg;
min-height:80px;
height:auto;
}

#menu-icon {
display: none
}

@media only screen and (max-width:640px) {
.header {
background-color: $yellow-bg;
min-height: 80px;
height: auto;
}

.nav{
justify-content: center;
position: relative;

&__item-container{
flex-direction:column;
position:absolute;
background-color:$yellow-bg;
width:100vw;
z-index: 3;
padding:14px 0;
top:17px;
left:-15px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.20);
}

&__item{
text-align:center;
font-size:16px;
font-weight: $font-weight-medium;
height:50px;
line-height: 50px;

&:not(:last-child){
margin-right:0
.nav {
justify-content: center;
position: relative;
&__item-container {
flex-direction: column;
position: absolute;
background-color: $yellow-bg;
width: 100vw;
z-index: 3;
padding: 14px 0;
top: 17px;
left: -15px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.20);
display: none;
}
&__item {
text-align: center;
font-size: 16px;
font-weight: $font-weight-medium;
height: 50px;
line-height: 50px;
&:not(:last-child) {
margin-right: 0
}
}
}
}

#menu-icon{
display:block;
position:absolute;
right:0;
top:-40px;

&:focus{
outline:none;
}

svg{
width:34px;
height:34px;

path{
stroke: $purple;
#menu-icon {
display: block;
position: absolute;
right: 0;
top: -40px;
&:focus {
outline: none;
}
svg {
width: 34px;
height: 34px;
path {
stroke: $purple;
}
}
}
}
}
}
Loading