[object Object]

← back to Retrowalls

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

5774b97fe19bd39bf94c9a82a1bd1024e10c476c · 2026-05-14 08:48:50 -0700 · Steve

Files touched

Diff

commit 5774b97fe19bd39bf94c9a82a1bd1024e10c476c
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu May 14 08:48:50 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    |  10 ++++-
 3 files changed, 226 insertions(+), 1 deletion(-)

diff --git a/data/hero-4grid.json b/data/hero-4grid.json
new file mode 100644
index 0000000..f56f0c0
--- /dev/null
+++ b/data/hero-4grid.json
@@ -0,0 +1,113 @@
+{
+  "cells": [
+    {
+      "kind": "room",
+      "sku": "chinese-fret-walls-cfw-9488",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/cfw-9488-sample-chinese-fret-hollywood-wallcoverings.jpg?v=1775708059",
+      "title": "Chinese Fret | Hollywood Wallcoverings"
+    },
+    {
+      "kind": "pattern",
+      "sku": "programa-piento-durable-vinyl-dur-72423",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/DUR-72423-sample-clean.jpg?v=1774485490",
+      "title": "Programa Piento Durable Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "kind": "room",
+      "sku": "dwtt-71755-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/T35142_ea8998c2-18c1-4a30-890d-5f17c3991340.jpg?v=1733893471",
+      "title": "Bahia Metallic Gold on Pearl on White | Thibaut"
+    },
+    {
+      "kind": "pattern",
+      "sku": "canal-stripe-texture-durable-walls-xwd-52106",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xwd-52106-sample-canal-stripe-texture-durable-hollywood-wallcoverings.jpg?v=1775707089",
+      "title": "Canal Stripe Texture Durable | Hollywood Wallcoverings"
+    }
+  ],
+  "rotation_pool": [
+    {
+      "sku": "chinese-fret-walls-cfw-9488",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/cfw-9488-sample-chinese-fret-hollywood-wallcoverings.jpg?v=1775708059",
+      "title": "Chinese Fret | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "programa-piento-durable-vinyl-dur-72423",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/DUR-72423-sample-clean.jpg?v=1774485490",
+      "title": "Programa Piento Durable Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "dwtt-71755-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/T35142_ea8998c2-18c1-4a30-890d-5f17c3991340.jpg?v=1733893471",
+      "title": "Bahia Metallic Gold on Pearl on White | Thibaut"
+    },
+    {
+      "sku": "canal-stripe-texture-durable-walls-xwd-52106",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xwd-52106-sample-canal-stripe-texture-durable-hollywood-wallcoverings.jpg?v=1775707089",
+      "title": "Canal Stripe Texture Durable | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "meander-border-metallic-red-wallcovering-versace",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/a8132d7035c2674e2606f3bca5cf7837.jpg?v=1773706318",
+      "title": "Meander Border Metallic, Red Wallcovering | Versace"
+    },
+    {
+      "sku": "pearl-bay-vertical-faux-durable-walls-xwh-52375",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/perplex-jetstream.jpg?v=1777480544",
+      "title": "Pearl Bay Vertical Faux Durable | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "hollywood-modern-wood-xhw-2010206",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/intarsia-tessellate_8d1a14da-5dcf-456f-a085-5dd463f1cf27.jpg?v=1777481266",
+      "title": "Hollywood Modern Wood | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "tony-s-thick-embossed-vinyl-xtt-44472",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xtt-44472-sample-tony-s-thick-embossed-vinyl-hollywood-wallcoverings.jpg?v=1775735340",
+      "title": "Tony's Thick Embossed Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "brooker-contemporary-durable-walls-xww-52997",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/gramercy-wire_glass.jpg?v=1777480747",
+      "title": "Brooker Contemporary Durable | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "wolfgordonwallcovering_dwwg_dpaw-462-jpg",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/DPAW-462_2021-02-18-235213.jpg?v=1762291450",
+      "title": "Pawpaw - Wedgewood | Wolf Gordon Wallcoverings"
+    },
+    {
+      "sku": "dwtt-71858-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/T16026_82d100cf-5114-4664-b745-25f9809ea9db.jpg?v=1733893245",
+      "title": "South Sea Navy | Thibaut"
+    },
+    {
+      "sku": "eloise-ivory-damask-wallpaper-cca-82997",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/e37cd31df4b1972029fb0743c9f84f16.jpg?v=1572309964",
+      "title": "Eloise Ivory Damask Wallcovering"
+    },
+    {
+      "sku": "eur-80312-ncw4302-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/nina_crop_7513503563827.jpg?v=1775523307",
+      "title": "Mourlot 02 - Grey Wallcovering | Nina Campbell"
+    },
+    {
+      "sku": "canal-damask-durable-vinyl-xwa-52078",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xwa-52078-sample-canal-damask-durable-vinyl-hollywood-wallcoverings.jpg?v=1775707053",
+      "title": "Canal Damask Durable Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "edgware-type-ii-vinyl-wallcovering-xlb-47641",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/xlb-47641-sample-edgware-type-ii-vinyl-hollywood-wallcoverings.jpg?v=1775711050",
+      "title": "Edgware Type II Vinyl | Hollywood Wallcoverings"
+    },
+    {
+      "sku": "dwtt-71963-designer-wallcoverings-los-angeles",
+      "image_url": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/T10001_b58f7522-2e00-420a-ab54-e15593192d87.jpg?v=1733893054",
+      "title": "Kalynn Metallic Pewter on Beige | Thibaut"
+    }
+  ],
+  "autocycle_seconds": 6,
+  "updated_at": "2026-05-14T15:38:53.396Z",
+  "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 f7438a6..396615e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -188,6 +188,13 @@ textarea:focus-visible,
 <meta name="twitter:description" content="Retro Walls — Vintage to midcentury wallcoverings — a curated archive.">
 <meta name="twitter:image" content="https://retrowalls.com/hero-bg.jpg">
 <!-- graphics-loop pass 13: footer + fb -->
+<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">
@@ -728,7 +735,8 @@ loadGridPage();
 </script>
 <!-- ============================================================
      DW UNIVERSAL CONTACT MODULE — fashion-house UX
-     Inject before </body> in every DW-family sister site.
+     Inject before   <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).
      ============================================================ -->

← 616e31a favicon: Mag-7-inspired SVG glyph  ·  back to Retrowalls  ·  hero-4grid: relocate json from data/ to public/ for Express 5679179 →