]> _ Git - pmi.git/commitdiff
WIP #3034 @8
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 17 Sep 2019 16:01:28 +0000 (18:01 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 17 Sep 2019 16:01:28 +0000 (18:01 +0200)
17 files changed:
package.json
resources/js/app.js
resources/js/components/CartItem.vue
resources/js/vendor/cubist/gtag/gtag.js
resources/styles/app.styl
resources/styles/common/grids.styl [new file with mode: 0644]
resources/styles/components/application.styl
resources/styles/components/cart.styl
resources/styles/components/form.styl
resources/styles/components/grids.styl [deleted file]
resources/styles/components/news.styl
resources/styles/components/product-gallery.styl
resources/styles/components/search.styl
resources/views/layouts/app.blade.php
resources/views/pages/news.blade.php
webpack.mix.js
yarn.lock

index ce2d4a96cf27ca2d9a1baf1bee0fa0ac2daeabb3..3a73abb88b1817b95f21bb61d3583da030e484e2 100644 (file)
@@ -16,6 +16,7 @@
         "browser-sync-webpack-plugin": "2.0.1",
         "cash-dom": "^4.1.5",
         "cross-env": "^5.2.0",
+        "css-vars-ponyfill": "^2.1.2",
         "element-closest": "^3.0.1",
         "element-closest-polyfill": "^1.0.0",
         "element-matches-polyfill": "^1.0.0",
index 90ca11b656265455bd55676937d874c0204c6b79..b410bcb475db910345ab4662294ee17ff1addba2 100644 (file)
@@ -7,7 +7,12 @@
 require('./bootstrap');
 require('./menu');
 require('../../vendor/cubist/cms-back/src/public/emailobfuscator/emailobfuscator');
-require("element-closest");
+require('element-closest');
+
+// Todo: WIP for CSS vars - need to assess MMenu usage and options for the polyfill. In default state, it's only partially working so it's better to disable this until it fully works.
+//import cssVars from 'css-vars-ponyfill';
+//cssVars({}); // Polyfill CSS Vars for older browsers
+
 
 var glob = require('glob');
 var path = require('path');
index 67d93fbd47138cc58b2c1096cad43e29d4e77ad8..f2d38d0fdc1e310babd198cd4555ebabe415f55f 100644 (file)
@@ -4,7 +4,7 @@
            :href="item.URL"
            :style="`background-image: url(${item.image});`">
         </a>
-        <div class="pl-6 xs:pl-0 leading-relaxed flex-grow">
+        <div class="cart-item-text pl-6 xs:pl-0 leading-relaxed flex-grow">
             <a :href="item.URL" class="block text-navy font-display">
 
                 <span class="text-grey-dark">{{ item.reference }}</span>
index 54c7b1eea556dd598c787308142681b9ac8761ff..be69a0369238291b3129c1eb8d46603a82f72977 100644 (file)
@@ -56,8 +56,10 @@ cubistga.prototype.event = function (action, category, label, value, noninteract
     if (undefined !== value && null !== value) {
         options.value = value;
     }
-    console.log('gtag event', action, options);
-    return gtag('event', action, options)
+
+    //console.log('gtag event', action, options);
+
+    return (typeof gtag !== "undefined") ? gtag('event', action, options) : false;
 };
 
 cubistga.prototype.handleGtag = function (el) {
index 596534a2026ac2a359432c3f06792ef8408346c4..09b5ba886fb823f97f528548fcb33bb4e56e31f4 100644 (file)
@@ -12,6 +12,7 @@
 // Extracted components or custom styles that can't be done with utilities
 @import 'common/spacing'
 @import 'common/columns'
+@import 'common/grids'
 @import 'common/global'
 @import 'common/headings'
 @import 'common/links'
diff --git a/resources/styles/common/grids.styl b/resources/styles/common/grids.styl
new file mode 100644 (file)
index 0000000..6d724cd
--- /dev/null
@@ -0,0 +1,130 @@
+// Generate utility classes for grids
+// Grid gaps are on 0.25vw jumps for greater control
+// Also some named gaps: sm, md, lg, xl
+$vw-spacing = {
+
+  'xs': 0.25vw,
+  'sm': 0.5vw,
+  'md': 1.25vw,
+  'lg': 2.5vw,
+  'xl': 5vw,
+
+  '1v': 0.25vw,
+  '2v': 0.5vw,
+  '3v': 0.75vw,
+  '4v': 1vw,
+  '5v': 1.25vw,
+  '6v': 1.5vw,
+  '7v': 1.75vw,
+  '8v': 2vw,
+  '9v': 2.25vw,
+  '10v': 2.5vw,
+  '20v': 5vw,
+}
+
+// Generate classes + make responsive
+
+@responsive
+  for id, vwAmount in $vw-spacing
+
+    .grid-gap-{id}
+      constrain(grid-gap, vwAmount)
+
+      // Non-CSS-Grid should have padding + negative margins to simulate grid gaps
+      // In the end this is a bit too complicated to do for not enough benefit so
+      // all grids can have the same fixed gap (see grid-fallback mixin)
+      //.no-cssgrid &
+      //  horizontal-spacing(vwAmount / -2, margin) // Negative half spacing on each side
+      //  > *
+      //    horizontal-spacing(vwAmount / 2) // Halved because padding will be doubled between neighbouring columns
+
+//----------------------------------
+
+// Fallback mixin for non-CSS-Grid columns
+$fallback_grid_gap = $vw-spacing.lg // Basis for all grid gaps and
+$fallback_grid_gap_px = unit($fallback_grid_gap / 100, '') * $base-width
+
+grid-fallback(cols, gap = $fallback_grid_gap) {
+  .no-cssgrid & {
+    > * {
+      lost-column: s('1/%s %s %s', cols, cols, gap)
+      margin-bottom: gap
+    }
+  }
+}
+
+//----------------------------------
+
+@responsive // Generate responsive utilities like sm:grid, md:grid-cols-2 etc
+  .grid
+    display: grid
+
+    .no-cssgrid &
+      display: flex
+      flex-wrap: wrap
+      margin-bottom: - $fallback_grid_gap
+
+    &-cols-auto
+      // Automatic number of columns based on number of children
+      // but with a min-width to stop them getting too small...
+      grid-template-columns: repeat(auto-fit, minmax(225px, 1fr))
+
+      // When there's no CSS Grid support, set columns based on breakpoints
+      grid-fallback(4)
+
+      +below(1500px)
+        grid-fallback(3)
+      +below(1100px)
+        grid-fallback(2)
+      +below(600px)
+        grid-fallback(1)
+
+
+    &-cols-1
+      grid-template-columns: 1fr
+      grid-fallback(1)
+
+    &-cols-2
+      grid-template-columns: repeat(2, 1fr)
+      grid-fallback(2)
+
+    &-cols-3
+      grid-template-columns: repeat(3, 1fr)
+      grid-fallback(3)
+
+    &-cols-4
+      grid-template-columns: repeat(4, 1fr)
+      grid-fallback(4)
+
+    &-cols-5
+      grid-template-columns: repeat(5, 1fr)
+      grid-fallback(5)
+
+
+  //&-cols-2
+  //
+  //  // Todo: consider using Modernizr so we can clean this up and only apply the .no-grid for IE11 and friends
+  //  // For IE11 and older browsers, use lost grid...
+  //  > *
+  //    lost-column: 1/2 2 1.25vw
+  //    margin-bottom: 1.25vw
+  //
+  //  @supports (display: grid)
+  //    grid-template-columns: repeat(auto-fill, minmax(225px, 1fr))
+  //
+  //    //Reset the lost-grid so it doesn't interfere
+  //    > *
+  //      lost-column: none
+  //      margin: 0 !important
+  //      flex-basis: auto
+  //      max-width: none
+  //
+  //      //// Internal block alignment - make sure text label sits at bottom
+  //      //display: flex
+  //      //flex-direction: column
+  //      //justify-content: space-between
+  //
+  //
+  //&-cols-3
+  //  @supports (display: grid)
+  //    grid-template-columns: repeat(3, 1fr)
index 54fa8004e2f7d1c3d5e956c9239d304cad59c252..e31df3a6d41c502408299b41ab513eebad02da40 100644 (file)
 
   &-body
     grid-area: body
+
+
+  .no-cssgrid &
+
+    &-layout
+      display: flex
+      align-items: flex-start
+
+      +below(700px)
+        display: block
+
+      > *
+        flex: 1 1 auto
+
+    &-body
+      padding: 0 2em
+
+      +below(700px)
+        padding: 2em 0
index fec5bced6f0b0359b097023f69990a875d4ae985..a413d3e5fca1c563b56cab288ccba9617b1de711 100644 (file)
       transition: max-height var(--transition-duration)
       overflow-y: auto
 
+      // IE 11 Flexbox
+      /*! purgecss start ignore */
+      .flexboxtweener &
+        .cart-item-text
+          flex: 1 1 0% // Fix for inconsistent sizing in IE11 (flex-basis must have unit)
+      /*! purgecss end ignore */
+
     &-footer
       @apply bg-grey-100 p-10
 
   &-image
     max-width: 144px
     max-height: @max-width
+
+// CSS Grid fallback
+.template-cart .grid-cols-auto
+  grid-fallback(2)
+
+  +below(850px)
+    grid-fallback(1)
index 06c2f74ef604fca32f1bd6848d7e142233e26d66..33b46903dfbfa87d0b4f68430f51822ce3240551 100644 (file)
       min-width: unset
       padding-left: 1.5em
       padding-right: @padding-left
+
+
+  // CSS Grid fallback
+  // Since forms can be used in multiple contexts (main / sidebar),
+  // it's not worth the complexity here in the fallback to accommodate
+  // the dual column layout because with only flexbox, the closest we
+  // can get is 2 columns without gaps OR a column gap but narrower
+  // fields than the full-width ones (because we don't know when
+  // the container will force a wrap)
+  .no-cssgrid &
+    .grid
+      display: flex
+      flex-wrap: wrap
+      justify-content: space-between
+      margin-bottom: 0
+
+    label
+      @apply block w-full
+      //min-width: 200px
+      //
+      //&.half
+      //  flex: 0 1 48%
diff --git a/resources/styles/components/grids.styl b/resources/styles/components/grids.styl
deleted file mode 100644 (file)
index 21a4c77..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// Generate utility classes for grids
-// Grid gaps are on 0.25vw jumps for greater control
-// Also some named gaps: sm, md, lg, xl
-$vw-spacing = {
-
-  'xs': 0.25vw,
-  'sm': 0.5vw,
-  'md': 1.25vw,
-  'lg': 2.5vw,
-  'xl': 5vw,
-
-  '1v': 0.25vw,
-  '2v': 0.5vw,
-  '3v': 0.75vw,
-  '4v': 1vw,
-  '5v': 1.25vw,
-  '6v': 1.5vw,
-  '7v': 1.75vw,
-  '8v': 2vw,
-  '9v': 2.25vw,
-  '10v': 2.5vw,
-  '20v': 5vw,
-}
-
-// Generate classes + make responsive
-
-@responsive
-  for id, vwAmount in $vw-spacing
-
-    .grid-gap-{id}
-      constrain(grid-gap, vwAmount)
-
-      // Non-CSS-Grid should have padding + negative margins to simulate grid gaps
-      // In the end this is a bit too complicated to do for not enough benefit so
-      // all grids can have the same fixed gap (see grid-fallback mixin)
-      //.no-cssgrid &
-      //  horizontal-spacing(vwAmount / -2, margin) // Negative half spacing on each side
-      //  > *
-      //    horizontal-spacing(vwAmount / 2) // Halved because padding will be doubled between neighbouring columns
-
-//----------------------------------
-
-// Fallback mixin for non-CSS-Grid columns
-$fallback_grid_gap = $vw-spacing.lg // Basis for all grid gaps and
-$fallback_grid_gap_px = unit($fallback_grid_gap / 100, '') * $base-width
-
-grid-fallback(cols) {
-  .no-cssgrid & {
-    > * {
-      lost-column: s('1/%s %s %s', cols, cols, $fallback_grid_gap)
-      margin-bottom: $fallback_grid_gap
-    }
-  }
-}
-
-//----------------------------------
-
-@responsive // Generate responsive utilities like sm:grid, md:grid-cols-2 etc
-  .grid
-    display: grid
-
-    .no-cssgrid &
-      display: flex
-      flex-wrap: wrap
-      margin-bottom: - $fallback_grid_gap
-
-    &-cols-auto
-      // Automatic number of columns based on number of children
-      // but with a min-width to stop them getting too small...
-      grid-template-columns: repeat(auto-fit, minmax(225px, 1fr))
-
-      // When there's no CSS Grid support, set columns based on breakpoints
-      grid-fallback(4)
-
-      +below(1500px)
-        grid-fallback(3)
-      +below(1100px)
-        grid-fallback(2)
-      +below(600px)
-        grid-fallback(1)
-
-
-    &-cols-1
-      grid-template-columns: 1fr
-      grid-fallback(1)
-
-    &-cols-2
-      grid-template-columns: repeat(2, 1fr)
-      grid-fallback(2)
-
-    &-cols-3
-      grid-template-columns: repeat(3, 1fr)
-      grid-fallback(3)
-
-    &-cols-4
-      grid-template-columns: repeat(4, 1fr)
-      grid-fallback(4)
-
-    &-cols-5
-      grid-template-columns: repeat(5, 1fr)
-      grid-fallback(5)
-
-
-  //&-cols-2
-  //
-  //  // Todo: consider using Modernizr so we can clean this up and only apply the .no-grid for IE11 and friends
-  //  // For IE11 and older browsers, use lost grid...
-  //  > *
-  //    lost-column: 1/2 2 1.25vw
-  //    margin-bottom: 1.25vw
-  //
-  //  @supports (display: grid)
-  //    grid-template-columns: repeat(auto-fill, minmax(225px, 1fr))
-  //
-  //    //Reset the lost-grid so it doesn't interfere
-  //    > *
-  //      lost-column: none
-  //      margin: 0 !important
-  //      flex-basis: auto
-  //      max-width: none
-  //
-  //      //// Internal block alignment - make sure text label sits at bottom
-  //      //display: flex
-  //      //flex-direction: column
-  //      //justify-content: space-between
-  //
-  //
-  //&-cols-3
-  //  @supports (display: grid)
-  //    grid-template-columns: repeat(3, 1fr)
index 93a2c0bba8fff6b1df94a5e6eb675e928a201320..52d70ee9be839756c3dbed75eb1730b21cf61be2 100644 (file)
       width 100%;
 
 
+  // Non-CSS grid fallback
+  .no-cssgrid &
+
+    &-layout
+      display: flex
+
+      +below(900px)
+        display: block
+
+    &-articles
+      flex: 1 1 auto
+
+    &-sidebar
+      flex: 0 1 320px
+
+      +below(900px)
+        margin-top: 2em
+        max-width: none
+
+    &-article
+      display: flex
+
+      &-image
+        flex: 1 1 auto
+        width: 33%
+        max-width: 330px
+
+      &-text
+        flex: 1 1 67%
+        padding: 0 2em
+
+
+
 
 //=== Individual News Post
 // 3 column layout with image / text / sidebar
   &-sidebar
     grid-area: sidebar
     min-width: 320px
+
+
+  .no-cssgrid &
+
+    &-layout
+      display: flex
+      align-items: flex-start
+
+      +below(1200px)
+        display: block
+
+      > *
+        flex: 1 1 auto
+
+    &-body
+      padding: 0 2em
+
+      +below(1200px)
+        padding: 2em 0
+
index bb2229132a8f6e4455a6ae857bac779daca5b052..d3006c808ae821818808c8c83ae27b40a53da465 100644 (file)
     @apply w-full bg-center bg-cover pb-100p border-4 border-grey-100 cursor-pointer
 
   &-current
-    @apply border-grey-300
\ No newline at end of file
+    @apply border-grey-300
+
+
+  // Non CSS Grid
+  .grid
+    grid-fallback(3, 15px)
+
+  .no-cssgrid &
+    &-thumb
+      padding-bottom: calc(33.3% - 10px)
index 6bb48d854d89ee19db45d08c01e9494cdaf7b237..6ba4e6758bae44de5101ded65b81045b8fabd57b 100644 (file)
@@ -30,6 +30,25 @@ $breakpoint-search-results = 980px
         @apply w-full mb-4
 
 
+  // Non CSS Grid fallback
+  .no-cssgrid &
+    &-layout
+      @apply flex
+
+      +below($breakpoint-search-results)
+        @apply block
+
+    &-main
+      flex: 1 1 0%
+
+    &-sidebar
+      @apply ml-8
+      flex: 0 0 320px
+
+      +below($breakpoint-search-results)
+        @apply ml-0 mt-6
+
+
 //== Autocomplete field
 /*! purgecss start ignore */
 .autocomplete
index 5ba1e1f57c08395bf8eb4720be43ca83b9fa7083..ea81d1558e0bf7d887b487784a2028741d2c34cd 100644 (file)
@@ -34,7 +34,7 @@
         </full-width>
     @show
 
-    <main class="flex-grow">
+    <main class="flex-grow h-full">
         @yield('content')
     </main>
 
index a4f4e7dec648b08157beb597e048a040cce08dc4..6a7a60a087eb82c28a47a5bfb06e597a1d7581b3 100644 (file)
@@ -1,7 +1,7 @@
 @extends('layouts.app')
 
 @section('content')
-    @intro(['padding' => 'pb-4v'])
+    @intro(['padding' => 'pb-2v'])
     <full-width padding="pb-3v">
         <content>
 
index 432a6e6f6347841e838267d14f53aa86e128dbb1..670cd2e7d21eef531ecc18949bd9310a4276fade 100644 (file)
@@ -17,6 +17,8 @@ mix.webpackConfig({
             ],
             'feature-detects': [
                 'css/cssgrid',
+                'css/flexbox',
+                'css/flexboxtweener',
             ]
         }),
     ],
@@ -71,6 +73,8 @@ if (mix.inProduction()) {
     mix.version(); // Enable unique hashed filenames when in production
 
     // Transpile code for older browsers like IE11
+    // This has to be here because if it is in the default setup,
+    // it seems to cause BrowserSync to go into an infinite loop :(
     mix.babel(['public/js/app.js'], 'public/js/app.js');
 }
 
index df849317858cc58f598f7b4b286b133802b4f1b7..3883fd8e1f34d6b8d4c2dd88c95f71acd0d660a5 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -2375,6 +2375,11 @@ css-url-regex@^1.1.0:
   resolved "https://registry.yarnpkg.com/css-url-regex/-/css-url-regex-1.1.0.tgz#83834230cc9f74c457de59eebd1543feeb83b7ec"
   integrity sha1-g4NCMMyfdMRX3lnuvRVD/uuDt+w=
 
+css-vars-ponyfill@^2.1.2:
+  version "2.1.2"
+  resolved "https://registry.yarnpkg.com/css-vars-ponyfill/-/css-vars-ponyfill-2.1.2.tgz#0de2e49e72a6bac09cb456a0325c8584cadaecd2"
+  integrity sha512-Jfff/j2AGwr+WJaIbxVroTa9sFXy9b0xe5zjWEVQ9aoeCpd0e6iOo4D+d3OoLDTWcHCf2UBTswis/hN6fKEKiA==
+
 css-what@^2.1.2:
   version "2.1.3"
   resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2"