From: Stephen Cameron Date: Mon, 18 Nov 2019 19:16:38 +0000 (+0100) Subject: WIP #3053 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3700a661197e2ede001d229e328c0ae7818b7138;p=ccv-wordpress.git WIP #3053 --- diff --git a/wp-content/themes/CCV/resources/assets/scripts/menu.js b/wp-content/themes/CCV/resources/assets/scripts/menu.js index f614147..7814c51 100644 --- a/wp-content/themes/CCV/resources/assets/scripts/menu.js +++ b/wp-content/themes/CCV/resources/assets/scripts/menu.js @@ -29,7 +29,9 @@ document.addEventListener( if (null === document.querySelector('#close-menu')) { - nav.innerHTML = '' + nav.innerHTML; + //nav.innerHTML = '' + nav.innerHTML; + + nav.innerHTML = '' + nav.innerHTML; document.querySelector('#close-menu').addEventListener('click', (event) => { mmenu.close(); @@ -41,12 +43,19 @@ document.addEventListener( function buildMobileMenu() { const menu = document.createElement('div'); + const menuOpener = document.createElement('a'); const menuWrapper = document.createElement('div'); const menuItems = document.querySelector('.main-menu').cloneNode(true); const ctaButtons = document.querySelectorAll('.header-cta'); const locales = document.querySelectorAll('.nav-secondary .locales a'); const localeLinks = Array.from(locales).reduce((html, link) => html + link.outerHTML, ''); + // Make mobile menu opener link + menuOpener.href = '#menu'; + menuOpener.className = 'mobile-menu-trigger'; + menuOpener.innerHTML = '
'; // Empty div needed for styling purposes to draw the 3 burger icon lines + document.body.appendChild(menuOpener); + // Prepend CTA links from header into main menu // ctaButtons is a NodeList so we convert to an array to allow it to be reversed // It needs to be reversed because we will prepend these links and we want the diff --git a/wp-content/themes/CCV/resources/assets/styles/components/header.styl b/wp-content/themes/CCV/resources/assets/styles/components/header.styl index ef10428..9d84420 100644 --- a/wp-content/themes/CCV/resources/assets/styles/components/header.styl +++ b/wp-content/themes/CCV/resources/assets/styles/components/header.styl @@ -10,7 +10,3 @@ header.site width: 100% background-color: transparent z-index: 20 - -.mobile-menu-trigger - +above($breakpoint-menu) - display: none diff --git a/wp-content/themes/CCV/resources/assets/styles/components/mmenu.styl b/wp-content/themes/CCV/resources/assets/styles/components/mmenu.styl index 8165fb1..a9c2942 100644 --- a/wp-content/themes/CCV/resources/assets/styles/components/mmenu.styl +++ b/wp-content/themes/CCV/resources/assets/styles/components/mmenu.styl @@ -2,6 +2,9 @@ --mm-width: 90% --mm-max-width: 308px +.mm-blocker + background-color: rgba(#2E2C40, 0.8) + #mobile-menu @apply bg-purple-dark text-white antialiased font-size: 16px fixed @@ -96,6 +99,7 @@ height: @width z-index: 1 cursor: pointer + outline: none display: none transition: color 0.2s @@ -108,3 +112,49 @@ // Only display at the top level of the menu .mm--main & display: block + +//================== + +// Burger menu icon + animation +.mobile-menu-trigger + position: absolute + width: 30px + height: @width + top: @width + right: @width + padding: 5px 0 // To match size of close X inside menu + display: flex + flex-direction: column + justify-content: space-between + z-index: 10000 // Needs to sit above MMenu + + +above($breakpoint-menu) + display: none + + &:hover + @apply text-pink + + &:after, &:before, div // 3 lines in burger icon + content: '' + width: 100% + background-color: currentColor + display: block + height: 2px + transition: all 0.3s ease-in-out + + &:after // Shorter bottom line + width: 50% + + // Morph to a cross when menu opens + .mm-body--open & + color: #fff // Controls colour of lines + + &:before // Top line + transform: translateY(9px) rotate(135deg) + + &:after // Bottom line + transform: translateY(-9px) rotate(-135deg) + width: 100% + + div // Middle line + transform: scale(0) diff --git a/wp-content/themes/CCV/resources/views/partials/header.blade.php b/wp-content/themes/CCV/resources/views/partials/header.blade.php index e8fb72f..f404030 100644 --- a/wp-content/themes/CCV/resources/views/partials/header.blade.php +++ b/wp-content/themes/CCV/resources/views/partials/header.blade.php @@ -11,8 +11,6 @@ - - @svg('menu', 'fill-current') @endif