]> _ Git - usines-reunies.git/commitdiff
WIP #4064 @7.75
authorStephen Cameron <stephen@cubedesigners.com>
Mon, 7 Dec 2020 20:12:28 +0000 (21:12 +0100)
committerStephen Cameron <stephen@cubedesigners.com>
Mon, 7 Dec 2020 20:12:28 +0000 (21:12 +0100)
.gitignore
web/app/mu-plugins/cube/src/CPT/Realisation.php [new file with mode: 0644]
web/app/mu-plugins/cube/src/Init.php
web/app/mu-plugins/typerocket/config/app.php
web/app/themes/Usines/package.json
web/app/themes/Usines/resources/assets/scripts/app.js
web/app/themes/Usines/resources/assets/scripts/menu.js [new file with mode: 0644]
web/app/themes/Usines/resources/assets/styles/components/navigation-mobile.styl [new file with mode: 0644]
web/app/themes/Usines/resources/views/partials/header.blade.php
web/app/themes/Usines/yarn.lock

index 60865870e7eb766769ff46f8887fed200c7a8d98..6639ba7455d764b4a591e92a02831df1483933a6 100644 (file)
@@ -15,6 +15,9 @@ web/app/upgrade
 web/app/uploads/*
 !web/app/uploads/.gitkeep
 
+# Translations
+web/app/languages
+
 # WordPress
 web/wp
 web/.htaccess
diff --git a/web/app/mu-plugins/cube/src/CPT/Realisation.php b/web/app/mu-plugins/cube/src/CPT/Realisation.php
new file mode 100644 (file)
index 0000000..a1ff3b0
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+namespace Cube\CPT;
+
+class Realisation {
+
+    public function register() {
+
+        // Wait for TypeRocket to load before adding post type
+        add_action('typerocket_loaded', function() {
+
+            $realisation = tr_post_type('Réalisation')
+                ->setId('realisation') // Set manually because accent in name isn't handled properly
+                ->setSlug('realisations')
+                ->setIcon('store')
+                ->setArgument('supports', ['title']) // No editor for this post type
+                ->setTitlePlaceholder(__('Titre de la réalisation', 'usines'))
+                ->setTitleForm(function() {
+                    $form = tr_form();
+
+                    echo $form->image('Thumbnail')
+                        ->setLabel(__('Vignette', 'usines'))
+                        ->setHelp(__("Utilisé sur la page d'index", 'usines'));
+
+                    echo $form->image('Hero Image')
+                        ->setLabel(__("Image d'en-tête", 'usines'));
+
+                    echo $form->textarea('Description');
+
+                    echo $form->repeater('Photos')->setFields([
+                        $form->image('Photo'),
+                    ]);
+
+                    echo $form->textarea('Testimonial')
+                        ->setLabel(__('Témoignage', 'usines'));
+
+                    echo $form->text('Testimonial Author')
+                        ->setLabel(__('Auteur du témoignage', 'usines'));
+                });
+
+            // Add Realisation Category taxonomy
+            tr_taxonomy('Catégorie')
+                ->setId('realisation_category')
+                ->setHierarchical(true)
+                ->apply($realisation);
+
+        });
+    }
+
+}
index fed9d2486807158c82d7d512b05302f2bdfec0dc..f54b7db2a0dc139719dd0bb1b6c434db2a99960d 100644 (file)
@@ -15,6 +15,7 @@ final class Init { // Marked as final because this class should never be extende
         return [
             Common\Setup::class,
             Customizer\Setup::class,
+            CPT\Realisation::class,
             Elementor\Setup::class,
         ];
     }
index 3603f9592821bde8e35b629b1e16ca2c8a2a2baa..c59815f3a1c50e10b03ef87e683640f282d22408 100644 (file)
@@ -9,9 +9,9 @@ return [
     |
     */
     'extensions' => [
-        '\TypeRocket\Extensions\TypeRocketUI',
         '\TypeRocket\Extensions\PostMessages',
-        '\TypeRocket\Extensions\PageBuilder',
+        //'\TypeRocket\Extensions\TypeRocketUI',
+        //'\TypeRocket\Extensions\PageBuilder',
     ],
 
     /*
index fba0fd74bf180efaaae0576fb04bbccce5280593..8207959915cba97259c42b38d20c98ca5cee5d1f 100644 (file)
@@ -46,6 +46,7 @@
     "purgecss-with-wordpress": "^2.3.0",
     "rimraf": "^3.0.2",
     "rupture": "^0.7.1",
+    "sidr": "^2.2.1",
     "stylelint": "^13.6.1",
     "stylelint-config-standard": "^20.0.0",
     "stylus": "github:acidjazz/stylus#dev",
index 3616f1c66308c0c8f476d0cdb576aee7f0ba1bab..0952d8a8cc546631244214a90c34d31c375ce190 100644 (file)
@@ -2,6 +2,7 @@
  * External Dependencies
  */
 import 'jquery';
+import './menu';
 
 $(document).ready(() => {
   // console.log('Hello world');
diff --git a/web/app/themes/Usines/resources/assets/scripts/menu.js b/web/app/themes/Usines/resources/assets/scripts/menu.js
new file mode 100644 (file)
index 0000000..67bdf69
--- /dev/null
@@ -0,0 +1,34 @@
+import sidr from 'sidr/dist/jquery.sidr'; // eslint-disable-line
+
+// Mobile menu setup
+let menuID = 'mobile-menu';
+let menuOpenerID = `${menuID}-opener`;
+
+$(document).ready(() => {
+
+  // Add menu opener icon
+  $(`<a href="#${menuID}" id="${menuOpenerID}"><div></div></a>`).appendTo('body');
+
+  // Add menu overlay element
+  $(`<div id="${menuID}-overlay"></div>`).appendTo('body');
+
+  // Configure Sidr
+  $(`#${menuOpenerID}`).sidr({
+    name: menuID,
+    side: 'left',
+    speed: 500, // Animation speed
+    displace: false, // Push body content when opening?
+    renaming: false, // Rename existing classes / IDs?
+  });
+
+  // Auto-close mobile menu when links are clicked or we click on the overlay
+  $(`#${menuID}-overlay, #${menuID} a`).on('click', function (event) {
+    $.sidr('close', menuID);  // close the menu
+
+    // Don't follow empty links (eg. close button)
+    if ($(this).attr('href') === '#') {
+      event.preventDefault();
+    }
+  });
+
+});
diff --git a/web/app/themes/Usines/resources/assets/styles/components/navigation-mobile.styl b/web/app/themes/Usines/resources/assets/styles/components/navigation-mobile.styl
new file mode 100644 (file)
index 0000000..86bbcc1
--- /dev/null
@@ -0,0 +1,99 @@
+@import '~sidr/dist/stylesheets/jquery.sidr.bare.css'
+
+// Actual menu built by Sidr plugin
+#mobile-menu
+  background-color: #fff
+  padding: 80px 30px 30px
+  width: 320px
+  z-index: 1000
+
+  +above($breakpoint-menu)
+    display: none
+
+  // The default Sidr CSS has fixed offsets for hiding the menu so we need to fix that...
+  &.right
+    right: -100%
+  &.left
+    left: -100%
+
+  .menu-item
+    padding: 0.5em 0
+    border-bottom: 1px solid #D4D4D4
+
+  // Content overlay when menu is open
+  &-overlay
+    position: fixed
+    top: 0
+    right: 0
+    bottom: 0
+    left: 0
+    background: rgba(#000, 0.25)
+    z-index: 20
+    pointer-events: none
+    opacity: 0
+    transition: opacity 0.2s ease-out
+
+    // Make visible once menu is opened
+    .sidr-open &
+      opacity: 1
+      pointer-events: auto
+
+
+  //=== Burger menu icon + animation
+  &-opener
+    position: fixed
+    width: 30px
+    height: @width
+    top: @width
+    left: @width
+    padding: 5px 0 // To match size of close X inside menu
+    display: flex
+    flex-direction: column
+    justify-content: space-between
+    z-index: 2000 // Needs to sit above Sidr
+    pointer-events: auto // MMenu disables pointer events outside the menu when it's open
+    transform: translateZ(0)
+    transition-property: opacity
+    transition-duration: 0.3s
+
+    // 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
+
+    &:hover
+      @apply text-red !important
+
+    &: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
+    .sidr-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)
index bf645043d3655824f1f71e5de0d6ac9d8aa84f3c..b6db07beaeab655b6018cdf60e8188c1504eba0e 100644 (file)
     <img src="@asset('images/icons/phone-circle.svg')" class="w-14 ml-2">
   </a>
 
+
+  {{-- Mobile menu --}}
+  <nav id="mobile-menu">
+    {{--<a href="#" class="close" aria-label="<?= _('Fermer le menu') ?>">@svg('menu-close', ['class' => 'menu-close-icon'])</a>--}}
+
+    <ul class="nav-items">
+      <li class="menu-item"><a href="{{ get_home_url() }}">{{ __('Accueil', 'usines') }}</a></li>
+
+      @if (has_nav_menu('primary_navigation_left'))
+        {!! wp_nav_menu([
+            'theme_location' => 'primary_navigation_left',
+            'container' => '',
+            'items_wrap' => '%3$s', // No UL wrapper element
+            'echo' => false,
+          ])
+        !!}
+      @endif
+
+      @if (has_nav_menu('primary_navigation_right'))
+          {!! wp_nav_menu([
+              'theme_location' => 'primary_navigation_right',
+              'container' => '',
+              'items_wrap' => '%3$s', // No UL wrapper element
+              'echo' => false,
+            ])
+          !!}
+      @endif
+    </ul>
+  </nav>
+
 </header>
index b8f2609671c80a2dd9d528c06e158feca00eded9..a7546a83edc621c97a47d6340f291ed9859566ac 100644 (file)
@@ -5989,7 +5989,7 @@ jest-worker@^25.1.0:
     merge-stream "^2.0.0"
     supports-color "^7.0.0"
 
-jquery@^3.5.1:
+jquery@>=1.4.3, jquery@^3.5.1:
   version "3.5.1"
   resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
   integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
@@ -8909,6 +8909,13 @@ shellwords@^0.1.1:
   resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
   integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
 
+sidr@^2.2.1:
+  version "2.2.1"
+  resolved "https://registry.yarnpkg.com/sidr/-/sidr-2.2.1.tgz#2291376575d2559f4b0c563f7d40e224dd3ecc70"
+  integrity sha1-IpE3ZXXSVZ9LDFY/fUDiJN0+zHA=
+  dependencies:
+    jquery ">=1.4.3"
+
 signal-exit@^3.0.0, signal-exit@^3.0.2:
   version "3.0.3"
   resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"