From 067f6098d390c8ec2893caf07a8227db3627a68d Mon Sep 17 00:00:00 2001 From: Ryan Parrish Date: Tue, 1 Oct 2024 10:12:55 -0600 Subject: [PATCH] MWPW-157888 - Hero marquee w/ no-min-height and no l/r padding when using a full-width variant in masonry(repost) (#2923) * conditional check for linkPic * Add `no-min-height` and check if elementIsEmpty before decorate row * revert decorate change. in diff pr * childNodes instead of specific elements * remove console * added test mocks for empty or element based bg content. Added style for -up .full-width * added better test coverage and simplified the isElementEmpty * simplified logic to check if head element is empty * removed unused func * fixed text mock markup --- libs/blocks/hero-marquee/hero-marquee.css | 7 ++++ libs/blocks/hero-marquee/hero-marquee.js | 11 ++++-- test/blocks/hero-marquee/mocks/body.html | 48 +++++++++++++++++++++-- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/libs/blocks/hero-marquee/hero-marquee.css b/libs/blocks/hero-marquee/hero-marquee.css index 34c9175a3f..f81a551f33 100644 --- a/libs/blocks/hero-marquee/hero-marquee.css +++ b/libs/blocks/hero-marquee/hero-marquee.css @@ -17,6 +17,7 @@ align-items: center; } +.hero-marquee.no-min-height { min-height: unset;} .hero-marquee.s-min-height { min-height: var(--s-min-height); } .hero-marquee.l-min-height { min-height: var(--l-min-height); } @@ -150,6 +151,12 @@ html[dir="rtl"] .hero-marquee .foreground { display: none; } +div[class*='-up'] .hero-marquee.has-bg.full-width, +div[class*='-up'] .hero-marquee.has-bg.grid-full-width { + padding-left: 0; + padding-right: 0; +} + /* Row Types */ .hero-marquee .row-list { text-align: left; diff --git a/libs/blocks/hero-marquee/hero-marquee.js b/libs/blocks/hero-marquee/hero-marquee.js index e464c7d3c2..200df7efce 100644 --- a/libs/blocks/hero-marquee/hero-marquee.js +++ b/libs/blocks/hero-marquee/hero-marquee.js @@ -123,6 +123,7 @@ function extendButtonsClass(copy) { button.classList.add('button-xl', 'button-justified-mobile'); }); } + function parseKeyString(str) { const regex = /^(\w+)\s*\((.*)\)$/; const match = str.match(regex); @@ -165,14 +166,16 @@ function loadBreakpointThemes() { export default async function init(el) { el.classList.add('con-block'); let rows = el.querySelectorAll(':scope > div'); - if (rows.length > 1 && rows[0].textContent !== '') { + if (rows.length <= 1) return; + const [head, ...tail] = rows; + rows = tail; + if (!head.textContent.trim() && !head.querySelector('picture', 'video')) { + head.remove(); + } else { el.classList.add('has-bg'); - const [head, ...tail] = rows; handleObjectFit(head); decorateBlockBg(el, head, { useHandleFocalpoint: true }); - rows = tail; } - // get first row that's not a keyword key/value row const mainRowIndex = rows.findIndex((row) => { const firstColText = row.children[0].textContent.toLowerCase().trim(); diff --git a/test/blocks/hero-marquee/mocks/body.html b/test/blocks/hero-marquee/mocks/body.html index 2031f3cd68..714fba6279 100644 --- a/test/blocks/hero-marquee/mocks/body.html +++ b/test/blocks/hero-marquee/mocks/body.html @@ -17,8 +17,12 @@
-
con-block-row-lockup (xl-icon-size)
-
XL Icon Size
+
con-block-row-lockup (xl-icon)
+
XL Icon
+
+
+
con-block-row-lockup
+
default size
@@ -30,7 +34,7 @@

This Hero has all row types

-
con-block-row-list (max-width-6-tablet)
+
con-block-row-list (max-width-6-tablet, xl-body)
+ +
+
+
+
+
+
+

Hero w/ empty bg row

+
+

This is the body

+
+
+ +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+

Hero w/ bg elements

+
+

This is the body

+
+