[object Object]

← back to Wallpapercanada

4-grid hero: drop-in script + crop CSS + initial 4 newest products

305f7801e264914d6c0f54fcff343a6017f300d2 · 2026-05-14 08:48:40 -0700 · Steve

Files touched

Diff

commit 305f7801e264914d6c0f54fcff343a6017f300d2
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu May 14 08:48:40 2026 -0700

    4-grid hero: drop-in script + crop CSS + initial 4 newest products
---
 data/hero-4grid.json | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
 public/hero-4grid.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++
 public/index.html    |   8 ++++
 3 files changed, 225 insertions(+)

diff --git a/data/hero-4grid.json b/data/hero-4grid.json
new file mode 100644
index 0000000..9de7e5d
--- /dev/null
+++ b/data/hero-4grid.json
@@ -0,0 +1,113 @@
+{
+  "cells": [
+    {
+      "kind": "room",
+      "sku": "daytona-faux-embossed-durable-walls-xwc-53274",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/XWC-53274-sample-clean.jpg?v=1774481955",
+      "title": "Daytona Faux Embossed Durable | Hollywood Wallcoverings"
+    },
+    {
+      "kind": "pattern",
+      "sku": "dwc-1001688",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/nina_crop_4693312503859.jpg?v=1775521609",
+      "title": "Nina Campbell Wallcovering"
+    },
+    {
+      "kind": "room",
+      "sku": "watch-hill-skin-wallcovering-phillipe-romano",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/Lgeuo23Gm0M07ExnghToQzwlxUUAVDrJiDQSdpl0.jpg?v=1776190093",
+      "title": "Watch Hill - Skin Wallcovering | Phillipe Romano"
+    },
+    {
+      "kind": "pattern",
+      "sku": "wolfgordonwallcovering_dwwg_sft-5019-jpg",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/sft-5019.jpg?v=1762305928",
+      "title": "Shift - Heather Gray | Wolf Gordon Wallcoverings"
+    }
+  ],
+  "rotation_pool": [
+    {
+      "sku": "daytona-faux-embossed-durable-walls-xwc-53274",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/XWC-53274-sample-clean.jpg?v=1774481955",
+      "title": "Daytona Faux Embossed Durable | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "dwc-1001688",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/nina_crop_4693312503859.jpg?v=1775521609",
+      "title": "Nina Campbell Wallcovering"
+    },
+    {
+      "sku": "watch-hill-skin-wallcovering-phillipe-romano",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/Lgeuo23Gm0M07ExnghToQzwlxUUAVDrJiDQSdpl0.jpg?v=1776190093",
+      "title": "Watch Hill - Skin Wallcovering | Phillipe Romano"
+    },
+    {
+      "sku": "wolfgordonwallcovering_dwwg_sft-5019-jpg",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/sft-5019.jpg?v=1762305928",
+      "title": "Shift - Heather Gray | Wolf Gordon Wallcoverings"
+    },
+    {
+      "sku": "hollywood-crystal-xhw-2010103",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/crystalline-indigo.jpg?v=1777480953",
+      "title": "Hollywood Crystal | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "faux-leaf-squares-fls-2510",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/fls-2510-sample-faux-leaf-squares-wallpaper-hollywood-wallcoverings.jpg?v=1775711889",
+      "title": "Faux Leaf Squares Wallpaper | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "wolfgordonwallcovering_dwwg_ad9504-jpg",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/WolfGordonWallcovering_DWWG_ad9503.jpg?v=1733874158",
+      "title": "Ambient Design - AD9504 | Wolf Gordon Wallcoverings"
+    },
+    {
+      "sku": "faux-leaf-squares-fls-2509",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/fls-2509-sample-faux-leaf-squares-wallpaper-hollywood-wallcoverings.jpg?v=1775711885",
+      "title": "Faux Leaf Squares Wallpaper | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "via-del-marnie-durable-vinyl-dur-72448",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/DUR-72448-sample-clean.jpg?v=1774485615",
+      "title": "Via del Marnie Durable Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "mazarin-by-innovations-usa-dwc-mazarin-3",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/Mazarin-3.jpg?v=1736198927",
+      "title": "Mazarin | Innovations USA"
+    },
+    {
+      "sku": "dwss-72650",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/707-21_image1_bc2d5e08-5cfc-4035-9e6e-4a9048d9be80.jpg?v=1646104950",
+      "title": "Murgröna light grey Sample Wallcovering | Sandberg"
+    },
+    {
+      "sku": "steuben-embossed-vertical-durable-vinyl-walls-xwr-52781",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xwr-52781-sample-steuben-embossed-vertical-durable-vinyl-hollywood-wallcoverings.jpg?v=1775734807",
+      "title": "Steuben Embossed Vertical Durable Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "mr-diorio-wallpaper-xa8-66464",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/7fa2495d98eebd02c237e9b257e59d12.jpg?v=1775124266",
+      "title": "Mr. Diorio Wallcovering"
+    },
+    {
+      "sku": "hollywood-modern-marble-xhw-2010320",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/selenite-quartz_4aee2540-66c9-4c4c-bad1-7c18b610a57b.jpg?v=1777481409",
+      "title": "Hollywood Modern Marble | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "hallandale-rice-paper-effect-durable-walls-xwt-53473",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/XWT-53473-sample-clean.jpg?v=1774482101",
+      "title": "Hallandale Rice Paper Effect Durable | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "eur-80443-ncw4494-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/nina_crop_7513508184115.jpg?v=1775524121",
+      "title": "Signature Meridor - Green Wallcovering | Nina Campbell"
+    }
+  ],
+  "autocycle_seconds": 6,
+  "updated_at": "2026-05-14T15:38:53.361Z",
+  "generated_by": "dw-4grid-fanout.js"
+}
\ No newline at end of file
diff --git a/public/hero-4grid.js b/public/hero-4grid.js
new file mode 100644
index 0000000..1bc244c
--- /dev/null
+++ b/public/hero-4grid.js
@@ -0,0 +1,104 @@
+/**
+ * hero-4grid.js — universal 2×2 rotating hero for DW-family sites.
+ *
+ * What it does:
+ *   - Fetches /data/hero-4grid.json on load
+ *   - Switches the hero to 4-square mode (data-hero-mode="four-square")
+ *   - Paints 4 cells with the configured images
+ *   - Auto-cycles each cell every N seconds, rotating through the pool
+ *   - Applies object-fit: cover; object-position: center 12% to ENFORCE
+ *     the "never show image with header" rule
+ *
+ * Drop-in:  <script src="/hero-4grid.js" defer></script>
+ *
+ * Per-site override: set window.Hero4GridConfig = { url, autocycle } before load.
+ */
+(function () {
+  'use strict';
+  if (window.__hero4GridLoaded) return;
+  window.__hero4GridLoaded = true;
+
+  var CFG = window.Hero4GridConfig || {};
+  var URL = CFG.url || '/data/hero-4grid.json';
+
+  function inject(cellEls, grid) {
+    // Switch hero mode
+    document.documentElement.dataset.heroMode = 'four-square';
+    var cinema = document.querySelector('.cinema');
+    if (!cinema) return;
+    // Build .cinema-grid if absent
+    var gridEl = cinema.querySelector('.cinema-grid');
+    if (!gridEl) {
+      gridEl = document.createElement('div');
+      gridEl.className = 'cinema-grid';
+      cinema.appendChild(gridEl);
+    }
+    gridEl.innerHTML = '';
+    for (var i = 0; i < 4; i++) {
+      var cell = document.createElement('div');
+      cell.className = 'cell hero4-cell';
+      cell.dataset.idx = i;
+      gridEl.appendChild(cell);
+    }
+    // Anti-header crop CSS — applied via inline so it ALWAYS wins
+    var style = document.createElement('style');
+    style.id = 'hero4-crop';
+    style.textContent =
+      '.hero4-cell{background-size:cover !important;background-position:center 12% !important;transition:opacity 600ms ease;}' +
+      '.hero4-cell.swap-out{opacity:0;}';
+    document.head.appendChild(style);
+
+    paint(grid);
+    if (grid.rotation_pool && grid.rotation_pool.length > 4) {
+      startRotation(grid);
+    }
+  }
+
+  function paint(grid) {
+    var cells = document.querySelectorAll('.hero4-cell');
+    for (var i = 0; i < cells.length; i++) {
+      var c = grid.cells[i];
+      if (c && c.image_url) {
+        cells[i].style.backgroundImage = "url('" + c.image_url + "')";
+        cells[i].title = c.title || '';
+      }
+    }
+  }
+
+  function startRotation(grid) {
+    var sec = Number(grid.autocycle_seconds) || 6;
+    var pool = grid.rotation_pool.slice();
+    // Index per cell — start with the next image after the initial 4
+    var nextIdx = [4 % pool.length, 5 % pool.length, 6 % pool.length, 7 % pool.length];
+    var cellIdx = 0;
+    setInterval(function () {
+      if (document.hidden) return; // pause when tab hidden
+      var cells = document.querySelectorAll('.hero4-cell');
+      var cell = cells[cellIdx];
+      if (!cell) return;
+      var next = pool[nextIdx[cellIdx] % pool.length];
+      if (!next || !next.image_url) { cellIdx = (cellIdx + 1) % 4; return; }
+      // Preload then swap
+      var pre = new Image();
+      pre.onload = function () {
+        cell.classList.add('swap-out');
+        setTimeout(function () {
+          cell.style.backgroundImage = "url('" + next.image_url + "')";
+          cell.title = next.title || '';
+          cell.classList.remove('swap-out');
+        }, 600);
+      };
+      pre.src = next.image_url;
+      nextIdx[cellIdx] = (nextIdx[cellIdx] + 4) % pool.length;
+      cellIdx = (cellIdx + 1) % 4;
+    }, sec * 1000);
+  }
+
+  fetch(URL, { credentials: 'same-origin' })
+    .then(function (r) { return r.ok ? r.json() : null; })
+    .then(function (grid) {
+      if (!grid || !grid.cells || !Array.isArray(grid.cells)) return;
+      inject(null, grid);
+    })
+    .catch(function (e) { console.warn('[hero-4grid] fetch failed:', e); });
+})();
diff --git a/public/index.html b/public/index.html
index 943672c..a05b6f6 100644
--- a/public/index.html
+++ b/public/index.html
@@ -174,6 +174,13 @@ textarea:focus-visible,
 <meta name="twitter:image" content="https://wallpapercanada.com/hero-bg.jpg">
 <!-- graphics-loop pass 13: footer + fb -->
 <script>if((location.search+location.hash).indexOf("figmacapture=")>=0){var s=document.createElement("script");s.src="https://mcp.figma.com/mcp/html-to-design/capture.js";s.async=true;document.head.appendChild(s);}</script>
+<style id="hero4-anti-header-crop">
+/* Never-show-images-with-headers rule (2026-05-14): every hero image
+   is cropped to center 12% from the top to defeat vendor watermarks /
+   scraped-site chrome / banner overlays. */
+.cinema-bg, .hero4-cell, .cell { background-position: center 12% !important; }
+.card img, .product img { object-position: center 12% !important; }
+</style>
 </head>
 <body>
 <style id="ns-header-modal-styles">
@@ -840,6 +847,7 @@ loadGridPage();
 <!-- /DW-HAMBURGER-NAV v1 -->
 
 <script src="/corner-nav.js" defer></script>
+  <script src="/hero-4grid.js" defer></script>
 </body> in every DW-family sister site.
      Self-contained: CSS + 4 modals + JS submission handlers.
      Uses host site's CSS vars (--bg, --fg, --gold, --rule).

← 2da6733 favicon: Mag-7-inspired SVG glyph  ·  back to Wallpapercanada  ·  hero-4grid: relocate json from data/ to public/ for Express 131605d →