]> _ Git - ccv-wordpress.git/commitdiff
Wait #3715 @3.5
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 18 Jun 2020 13:14:29 +0000 (15:14 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 18 Jun 2020 13:14:29 +0000 (15:14 +0200)
wp-content/themes/CCV/app/setup.php
wp-content/themes/CCV/resources/assets/scripts/app.js
wp-content/themes/CCV/resources/assets/scripts/header.js [new file with mode: 0644]
wp-content/themes/CCV/resources/assets/scripts/menu.js
wp-content/themes/CCV/resources/assets/styles/common/admin.styl
wp-content/themes/CCV/resources/assets/styles/common/setup.styl
wp-content/themes/CCV/resources/assets/styles/components/header.styl
wp-content/themes/CCV/resources/assets/styles/components/mmenu.styl
wp-content/themes/CCV/resources/assets/styles/components/navigation.styl
wp-content/themes/CCV/resources/views/partials/header.blade.php

index fbbc5d89101a0cae67a3b16dc5c416e207a54f56..fa611b07dacd1e01c24d7c6f4e48fe9276c30076 100755 (executable)
@@ -59,7 +59,7 @@ add_action('wp_print_styles', function() {
  */
 add_action('wp_enqueue_scripts', function () {
     wp_enqueue_script('sage/vendor', asset('scripts/vendor.js')->uri(), [], null, true);
-    wp_enqueue_script('sage/app', asset('scripts/app.js')->uri(), ['sage/vendor'], null, true);
+    wp_enqueue_script('sage/app', asset('scripts/app.js')->uri(), ['sage/vendor', 'jquery'], null, true);
 
     wp_add_inline_script('sage/vendor', asset('scripts/manifest.js')->contents(), 'before');
 
index a28df340e06710e34f63d8faadae3bf6d4b69d04..59934d674649aeb6c2c552ee27ba67b44ff7e1fe 100644 (file)
@@ -3,6 +3,7 @@
  */
 import { router } from 'js-dom-router';
 import './menu';
+import './header';
 
 /**
  * DOM-based routing
diff --git a/wp-content/themes/CCV/resources/assets/scripts/header.js b/wp-content/themes/CCV/resources/assets/scripts/header.js
new file mode 100644 (file)
index 0000000..c2dfe89
--- /dev/null
@@ -0,0 +1,39 @@
+//== Auto-hiding sticky header
+// Adapted from https://codyhouse.co/gem/auto-hiding-navigation
+
+jQuery(document).ready(function($) {
+
+  let container = $('body'),
+  scrolling = false,
+  previousTop = 0,
+  currentTop = 0,
+  scrollDelta = 10,
+  scrollOffset = 200; // How far should we scroll before hiding the header
+
+  $(window).on('scroll', function(){
+
+    if (!scrolling) {
+      scrolling = true;
+      (!window.requestAnimationFrame)
+        ? setTimeout(autoHideHeader, 250)
+        : requestAnimationFrame(autoHideHeader);
+    }
+  });
+
+  function autoHideHeader() {
+    currentTop = $(window).scrollTop();
+
+    if (previousTop - currentTop > scrollDelta) {
+      // Scrolling up...
+      container.removeClass('header-hidden');
+
+    } else if (currentTop - previousTop > scrollDelta && currentTop > scrollOffset) {
+      // Scrolling down...
+      container.addClass('header-hidden');
+    }
+
+    previousTop = currentTop;
+    scrolling = false;
+  }
+
+});
index 9e31a445dec685b2bd04dedec1a70d61116e2885..f236e8e7d9e31b8f676f6e050b99110d55d98605 100644 (file)
@@ -14,7 +14,7 @@ document.addEventListener(
 
     let nav = document.getElementById(menuID);
     window.mmenu = new MmenuLight(nav, { title: '' });
-    window.menu_breakpoint = 1349; // Note: this should match the menu CSS breakpoint in setup.styl!
+    window.menu_breakpoint = 1023; // Note: this should match the menu CSS breakpoint in setup.styl!
 
     mmenu.enable(`(max-width: ${menu_breakpoint}px)`);
     mmenu.offcanvas({
index 27134dc9881520b8043255b7f63515b3c8602dc9..eb8c0cf60d2340a94e9cb54e0ac5dd0ce720862c 100644 (file)
@@ -13,6 +13,7 @@
 
 //===== Admin bar tweaks
 $breakpoint-admin-bar = 783px
+$breakpoint-admin-bar-absolute = 600px // When admin bar goes from being 'fixed' to 'absolute'
 $admin-bar-height = 32px
 $admin-bar-height-mobile = 46px
 
@@ -38,12 +39,22 @@ body.admin-bar
   +above($breakpoint-admin-bar)
     position: relative
 
-    #mobile-menu
+    header.site, #mobile-menu
       top: $admin-bar-height
 
+    .mobile-menu-trigger
+      top: 30px + $admin-bar-height
+
   +below($breakpoint-admin-bar)
-    #mobile-menu
+    header.site, #mobile-menu
       top: $admin-bar-height-mobile
 
     .mobile-menu-trigger
       top: 30px + $admin-bar-height-mobile
+
+  +below($breakpoint-admin-bar-absolute)
+    header.site, #mobile-menu
+      top: 0
+
+    .mobile-menu-trigger
+      top: 30px
index 71a78bb2f24125bb8e9480c7a5cca36a56f99c08..741acd7550573dad991d3128e0a155ab79d2bdf4 100644 (file)
@@ -14,7 +14,7 @@ $vertical-gutter   = 7.5vw
 
 // Breakpoints in Rupture (https://github.com/jescalan/rupture)
 $breakpoint-columns  = 768px // NOTE: this should align with the 'sm' screen value in tailwind.config.js
-$breakpoint-menu     = 1350px // This needs to match the MMenu activation setting in menu.js
+$breakpoint-menu     = 1024px // This needs to match the MMenu activation setting in menu.js
 rupture.scale        = 0 400px  768px   1024px
 rupture.scale-names  = 'small' 'medium' 'large'
 rupture.anti-overlap = -1px // Results in +below(1000px) being max-width: 999px and +above(1000px) being min-width: 1000px
index b14713bd42574d05ceaac76aff20ff94ca5bd408..fd1ba73fef028921d098a719632514fd4dd2f3a7 100644 (file)
@@ -1,16 +1,26 @@
 $breakpoint-slideshow = 1000px
 
 header.site
-  .header-slideshow-present &, .home & // Special case for home page and other pages containing this widget
-    //+above($breakpoint-menu)
-    +above($breakpoint-slideshow)
-      position: absolute
-      top: 0
-      left: 0
-      width: 100%
-      background-color: transparent
-      z-index: 20
+  transform: translateZ(0)
+  will-change: transform
+  transition: all 0.5s ease
+
+  .header-hidden &
+    transform: translateY(-100%)
+
+//  .header-slideshow-present &, .home & // Special case for home page and other pages containing this widget
+//    //+above($breakpoint-menu)
+//    +above($breakpoint-slideshow)
+//      position: absolute
+//      top: 0
+//      left: 0
+//      width: 100%
+//      background-color: transparent
+//      z-index: 20
 
 .header-cta
   padding: 1em 1.8em
   line-height: 1.1
+
+  +below(1100px)
+    padding: 0.75em 1.6em
index bb06096871c3de699d5480fab46f2878b8421448..8e2cc7cb10646dbb2623ca2787fb41b38bbae979 100644 (file)
@@ -101,7 +101,7 @@ $menu-header-height = 90px
 
 // Burger menu icon + animation
 .mobile-menu-trigger
-  position: absolute
+  position: fixed
   width: 30px
   height: @width
   top: @width
@@ -112,6 +112,21 @@ $menu-header-height = 90px
   justify-content: space-between
   z-index: 10000 // Needs to sit above MMenu
   pointer-events: auto // MMenu disables pointer events outside the menu when it's open
+  transform: translateZ(0)
+  transition-property: opacity
+  transition-duration: 0.3s
+  transition-delay: 0.2s // Delay before coming back into view when header slides down
+
+  // This icon can't be contained inside the header because it needs to sit at the
+  // highest stacking level so it can animate as menu opens and closes. As a result, when
+  // the header auto-hides, it doesn't take the icon with it so we need to handle it differently here
+  .header-hidden &
+    opacity: 0
+    pointer-events: none
+
+    // Set transition delay and duration to zero so it disappears immediately
+    transition-duration: 0s
+    transition-delay: 0s
 
   +above($breakpoint-menu)
     display: none
index 8ec0f5959a3c543404de84f7ca02e99eaa3ca4f6..fc9c8b8fd9cb9097c3115ebdf2c3d3a2cacc1f51 100644 (file)
     @apply border-b-2 border-transparent // Reserve space for active border
     @apply py-1 leading-tight // Adjust active border spacing
 
+    +below(1400px)
+      @apply mx-4
+    +below(1320px)
+      @apply mx-3
+    +below(1080px)
+      @apply mx-2
+
     &.current-menu-item, &.current-menu-parent
       @apply border-pink
 
index f13b62a3b2e703273290a673502743091530761e..3efa8f853249481c3f9df5de2c065564d9a06877 100644 (file)
@@ -1,7 +1,7 @@
-<header class="site bg-white font-display font-medium uppercase text-sm">
-  <div class="container relative pl-2v pr-1v pt-8 pb-12 flex items-center justify-between">
-    <a class="flex-shrink-0 mr-4"
-       style="max-width: 45%; min-width: 180px"
+<header class="site sticky top-0 z-20 bg-white font-display font-medium uppercase text-sm">
+  <div class="container relative px-1v py-8 flex items-center justify-between">
+    <a class="mr-4"
+       style="max-width: 45%"
        href="{{ home_url('/') }}"
        aria-label="<?= _("Go to the home page") ?>">
       <img class="header-logo" src="@asset('images/logo.svg')" alt="{{ get_bloginfo('name', 'display') }}">