From edfbfe509c0580bd21e1fba7533df2f29ec8f51d Mon Sep 17 00:00:00 2001 From: Iain Collins Date: Sat, 6 Jan 2018 12:16:40 +0000 Subject: [PATCH] Dropdown and nav menu toggle improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partly addresses issues in #57 * Dropdown menus in the nav menu on mobile now display correctly. * The nav menu no longer requires JavaScript to be enabled to work and uses a pure CSS solution. I may prototype to extend this to other components and see if it’s a pull request the Reactstrap folks would be interested in. --- components/layout.js | 95 ++++++++++++++++++++++++++++---------------- css/index.scss | 17 ++++++++ package.json | 2 +- 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/components/layout.js b/components/layout.js index c75d56c..0674bc5 100644 --- a/components/layout.js +++ b/components/layout.js @@ -28,16 +28,9 @@ export default class extends React.Component { isOpen: false, modal: false } - this.toggleNavbar = this.toggleNavbar.bind(this) this.toggleModal = this.toggleModal.bind(this) } - toggleNavbar() { - this.setState({ - isOpen: !this.state.isOpen - }) - } - toggleModal(e) { if (e) e.preventDefault() @@ -65,34 +58,66 @@ export default class extends React.Component { {Package.name} - - - - - + + + + {this.props.children} diff --git a/css/index.scss b/css/index.scss index c1f7844..9e6ad63 100644 --- a/css/index.scss +++ b/css/index.scss @@ -27,4 +27,21 @@ pre { .navbar .dropdown-item, .navbar button { font-size: 18px; +} + +/** + * This is a fix for Reactstrap 5.0.0-alpha.4 not displaying + * menus correctly. + **/ +.navbar .dropdown { + display: block; +} + +@media (max-width: 768px) { + .navbar .dropdown-menu { + position: relative !important; + display: block !important; + transform: none !important; + border: 0px; + } } \ No newline at end of file diff --git a/package.json b/package.json index 1493230..7766471 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nextjs-starter", - "version": "4.2.0", + "version": "4.2.1", "description": "A starter Next.js project with email and oAuth authentication", "author": "Iain Collins ", "license": "ISC",