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

Hamburger menu #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 16 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import React, { Component } from 'react';
import './App.css';
import Header from './Header';
import Menu from './Menu';

class App extends Component {
constructor(props) {
super(props);
this.state = {
isMenuVisible: false,
};
}

handleHamburgerClick() {
this.setState({
isMenuVisible: !this.state.isMenuVisible,
});
}

render() {
return (
<div className="App">
<Header />
<Header onClick={() => this.handleHamburgerClick()} />
<Menu isVisible={this.state.isMenuVisible} />
</div>
);
}
Expand Down
13 changes: 9 additions & 4 deletions src/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
line-height: 54px;
}

a {
.c-mobile-header-left {
height: 54px;
position: absolute;
vertical-align: middle;

background: rgba(255, 255, 255, 0.99);
}

.c-mobile-header-left {
top: 0;
bottom: 0;
left: 0;
Expand All @@ -29,9 +27,16 @@ a {
color: #303030;

z-index: 600;
cursor: pointer;
}

.c-mobile-header-logo {
height: 54px;
position: absolute;
vertical-align: middle;

background: rgba(255, 255, 255, 0.99);

display: block;
margin-left: auto;
margin-right: auto;
Expand All @@ -42,7 +47,7 @@ a {
z-index: 500;
}

img {
.c-mobile-header-logo-image {
vertical-align: middle;
width: 100%;
max-height: 24px;
Expand Down
4 changes: 2 additions & 2 deletions src/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Header extends Component {
render() {
return (
<div className="c-mobile-header">
<a class="c-mobile-header-left" href="#"><i class="fa fa-bars"></i></a>
<a class="c-mobile-header-logo" href="/"><img src={logo} type="text/css" /></a>
<a class="c-mobile-header-left" onClick={() => this.props.onClick()}><i class="fa fa-bars"></i></a>
<a class="c-mobile-header-logo" href="/"><img src={logo} class="c-mobile-header-logo-image" type="text/css" /></a>
</div>
);
}
Expand Down
22 changes: 22 additions & 0 deletions src/Menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.c-mobile-menu.visible {
background-color: white;
opacity: 0.90;
margin-top: 54px;
width: 33%;
color: #0070c9;
position: absolute;
height: calc(100vh - 54px);
min-height: calc(100vh - 54px);
top: 0;
z-index: 700;
border-right: 1px solid #DADADA;
}

.c-mobile-menu.invisible {
display: none;
}

.c-mobile-menu__header {
padding-top: 10px;
padding-bottom: 10px;
}
21 changes: 21 additions & 0 deletions src/Menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Component } from 'react';
import './Menu.css';
import MenuListing from './MenuListing';
import MenuAds from './MenuAds';

class Menu extends Component {
render() {
const isVisible = this.props.isVisible ? 'visible' : 'invisible';
return (
<div className="c-mobile-menu">
<div className={`c-mobile-menu ${isVisible}`}>
<div class="c-mobile-menu__header"><strong>Categories</strong></div>
<MenuListing />
<MenuAds />
</div>
</div>
);
}
}

export default Menu;
9 changes: 9 additions & 0 deletions src/MenuAds.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.c-mobile-menuads {
/*height: screen height - header bar - menu header - menu items - margins - ad box borders*/
height: calc(100vh - 54px - 38.4px - 227.2px - 45px - 4px);
}

.c-mobile-menuads__ad {
height: 50%;
border: 1px solid #DADADA;
}
19 changes: 19 additions & 0 deletions src/MenuAds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { Component } from 'react';
import './MenuAds.css';

class MenuAds extends Component {
render() {
return (
<div className="c-mobile-menuads">
<div class="c-mobile-menuads__ad">
Ad #1
</div>
<div class="c-mobile-menuads__ad">
Ad #2
</div>
</div>
);
}
}

export default MenuAds;
12 changes: 12 additions & 0 deletions src/MenuItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.c-mobile-menuitem {
margin-top: 5px;
margin-bottom: 5px;
margin-left: auto;
margin-right: auto;
padding-top: 5px;
padding-bottom: 5px;
background-color: #0070c9;
font-size: 16px;
color: white;
text-align: center;
}
14 changes: 14 additions & 0 deletions src/MenuItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Component } from 'react';
import './MenuItem.css';

class MenuItem extends Component {
render() {
return (
<div className="c-mobile-menuitem">
<strong>{this.props.category}</strong>
</div>
);
}
}

export default MenuItem;
Empty file added src/MenuListing.css
Empty file.
22 changes: 22 additions & 0 deletions src/MenuListing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Component } from 'react';
import './MenuListing.css';
import MenuItem from './MenuItem';

class MenuListing extends Component {
render() {
return (
<div className="MenuListing">
<MenuItem category='News' />
<MenuItem category='Culture' />
<MenuItem category='Features' />
<MenuItem category='Opinion' />
<MenuItem category='Sports' />
<MenuItem category='Blog' />
<MenuItem category='Science' />
<MenuItem category='Events' />
</div>
);
}
}

export default MenuListing;