From: Stephen Cameron Date: Thu, 18 Jul 2019 17:01:10 +0000 (+0200) Subject: WIP #2922 @6 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d15410a9b2a8ba21b7b0570a3b169ded4975ba80;p=pmi.git WIP #2922 @6 --- diff --git a/package.json b/package.json index 6310d35..6f68ec8 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "laravel-mix-purgecss": "^4.1.0", "lodash": "^4.17.5", "lost": "^8.3.1", + "mmenu-light": "^2.1.0", "popper.js": "^1.12", "portal-vue": "^2.1.5", "resolve-url-loader": "^2.3.1", diff --git a/resources/js/app.js b/resources/js/app.js index fded0ae..5b49d61 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -6,6 +6,7 @@ */ require('./bootstrap'); +require('./menu'); window.Vue = require('vue'); diff --git a/resources/js/menu.js b/resources/js/menu.js new file mode 100644 index 0000000..6e74df3 --- /dev/null +++ b/resources/js/menu.js @@ -0,0 +1,35 @@ +// Note: for now, mmenu-light doesn't support webpack properly +// so we're taking the contents of src/mmenu-light.js and placing +// it here in order to make the initialisation work correctly +// Ref: https://github.com/FrDH/mmenu-light/issues/7 + +//=============================================================== +// Core +import MmenuLight from 'mmenu-light/dist/js/mmlight'; + +// Add-ons +import offcanvas from 'mmenu-light/dist/js/mmlight.offcanvas'; + +MmenuLight.prototype.offcanvas = offcanvas; + +// Global namespace +window.MmenuLight = MmenuLight; +//=============================================================== + +//=== MMenu Setup +document.addEventListener( + 'DOMContentLoaded', () => { + const menuSelector = '#menu'; + const menu = new MmenuLight(document.querySelector(menuSelector)); + + menu.enable('all'); // or: '(max-width: 1000px)' + menu.offcanvas(); + + document.querySelector(`a[href="${menuSelector}"]`) + .addEventListener('click', (event) => { + menu.open(); + event.preventDefault(); + event.stopPropagation(); + }); + } +); diff --git a/resources/styles/app.styl b/resources/styles/app.styl index 0b868bd..596534a 100644 --- a/resources/styles/app.styl +++ b/resources/styles/app.styl @@ -6,6 +6,9 @@ @tailwind base @tailwind components +// MMenu base styles from NPM package +@import '~mmenu-light/dist/mmenu-light.css' + // Extracted components or custom styles that can't be done with utilities @import 'common/spacing' @import 'common/columns' diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index f8677ff..85b8b31 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -2,17 +2,19 @@
- + @if (config('features.quote'))
diff --git a/yarn.lock b/yarn.lock index 44c1bad..79c46d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4562,6 +4562,11 @@ mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1, mkdirp dependencies: minimist "0.0.8" +mmenu-light@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mmenu-light/-/mmenu-light-2.1.0.tgz#9387249d56649e3e776707e59a90ed018868cc10" + integrity sha512-s4FMXwYILw3UL7kpcjrDSXgn0AWEA+CQXnkrJhWEjLTONbHhFFI0Ln5BCQ4/kE6B5wD1WnR20o1eT8nAR7QYpw== + move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" @@ -6803,12 +6808,10 @@ stylus-loader@^3.0.2: dependencies: css-parse "~2.0.0" debug "~3.1.0" - glob "^7.1.3" + glob "~7.1.2" mkdirp "~0.5.x" - safer-buffer "^2.1.2" sax "~1.2.4" - semver "^6.0.0" - source-map "^0.7.3" + source-map "~0.7.2" supports-color@^2.0.0: version "2.0.0"