From 5ffc1e98436dc388a311a33da2aa11ffcbbb6566 Mon Sep 17 00:00:00 2001 From: mitchelljfs Date: Sun, 22 Jul 2018 01:02:43 -0700 Subject: [PATCH] Swapped out 3rd party responsive menu component and built out my own; version bump --- package.json | 3 +- src/Website.css | 7 ++-- src/Website.js | 2 +- src/components/Navbar/index.css | 20 +++++----- src/components/Navbar/index.js | 70 ++++++++++++++++++++++++--------- 5 files changed, 68 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index f8e0a2d..d2bbb81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-website", - "version": "0.2.20", + "version": "0.3.0", "private": true, "dependencies": { "@fortawesome/fontawesome": "^1.1.8", @@ -8,7 +8,6 @@ "@fortawesome/react-fontawesome": "^0.0.19", "react": "^16.3.2", "react-dom": "^16.3.2", - "react-responsive-navbar": "^1.0.11", "react-router-dom": "^4.2.2", "react-scripts": "1.1.4" }, diff --git a/src/Website.css b/src/Website.css index 1064f8a..cc0005c 100644 --- a/src/Website.css +++ b/src/Website.css @@ -8,15 +8,16 @@ .main-container { margin: auto; margin-top: 50px; - max-width: 500px; - min-width: 50%; + min-width: 800px; + width: 50%; text-align: center; } -@media screen and (max-width: 500px) { +@media screen and (max-width: 800px) { .main-container { margin-bottom: 50px; margin-top: auto; + min-width: 0; width: 100%; } } diff --git a/src/Website.js b/src/Website.js index 7728fc9..5a1ab04 100644 --- a/src/Website.js +++ b/src/Website.js @@ -14,7 +14,7 @@ class Website extends React.Component { return (
- +
diff --git a/src/components/Navbar/index.css b/src/components/Navbar/index.css index 77c15d2..fe877b9 100644 --- a/src/components/Navbar/index.css +++ b/src/components/Navbar/index.css @@ -7,12 +7,6 @@ top: 0; } -.navbar-small { - bottom: 0; - padding-bottom: 5px; - top: auto; -} - .navbar-button { background-color: rgb(139, 191, 209); border-radius: 2px; @@ -23,7 +17,7 @@ transition: box-shadow 0.1s; } -.navbar-button-close { +.navbar-button-closed { background-color: rgb(173, 184, 209); } @@ -32,7 +26,8 @@ } .navbar-menu { - margin: 0 23.75%; + margin: auto; + min-width: 840px; width: 52.5%; } @@ -62,9 +57,16 @@ background-color: rgb(139, 191, 209); } -@media screen and (max-width: 500px) { +@media screen and (max-width: 800px) { + .navbar { + bottom: 0; + padding-bottom: 5px; + top: auto; + } + .navbar-menu { margin: auto; + min-width: 0; width: 75%; } .navbar-menu-button { diff --git a/src/components/Navbar/index.js b/src/components/Navbar/index.js index 6a106d2..3b8db44 100644 --- a/src/components/Navbar/index.js +++ b/src/components/Navbar/index.js @@ -1,6 +1,5 @@ // @flow import React from "react" -import ResponsiveMenu from "react-responsive-navbar" import { NavLink } from "react-router-dom" import FontAwesomeIcon from "@fortawesome/react-fontawesome" import faBars from "@fortawesome/fontawesome-free-solid/faBars" @@ -9,30 +8,60 @@ import "./index.css" type Props = {} -class Navbar extends React.Component { +type State = { + showMenu: boolean +} + +class Navbar extends React.Component { + static defaultProps: Props + changeMenu: number + + constructor(props: Props) { + super(props) + this.changeMenu = 800 + + if (window.innerWidth <= this.changeMenu) { + this.state = { showMenu: false } + } else { + this.state = { showMenu: true } + } + } + + toggleMenu = () => { + if (window.innerWidth <= this.changeMenu || !this.state.showMenu) { + this.setState(prev => ({ showMenu: !prev.showMenu })) + } + } + render() { + let menuButton = null + + if (window.innerWidth <= this.changeMenu) { + menuButton = ( +
+ +
+ ) + } + return ( - - -
- } - menuCloseButton={ -
- -
- } - changeMenuOn="500px" - largeMenuClassName="navbar" - smallMenuClassName="navbar navbar-small" - menu={ +
+ {menuButton} + {this.state.showMenu ? (
Home @@ -40,6 +69,7 @@ class Navbar extends React.Component { className="navbar-menu-button" activeClassName="active-button" to="/projects" + onClick={this.toggleMenu} > Projects @@ -47,6 +77,7 @@ class Navbar extends React.Component { className="navbar-menu-button" activeClassName="active-button" to="/experience" + onClick={this.toggleMenu} > Experience @@ -54,12 +85,13 @@ class Navbar extends React.Component { className="navbar-menu-button" activeClassName="active-button" to="/contact" + onClick={this.toggleMenu} > Contact
- } - /> + ) : null} +
) } }