Skip to content

Commit

Permalink
MWPW-156865 - Hero marquee supports heading element on detail text. (#…
Browse files Browse the repository at this point in the history
…2801)

* enabled config for `allowDetailHeading` on the shared decorateBlockText

* hasDetailHeading - refactor so all but first still get decorated
  • Loading branch information
ryanmparrish authored Sep 5, 2024
1 parent 3f32a64 commit 8ea4f29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/hero-marquee/hero-marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default async function init(el) {
: null;
if (assetUnknown) assetUnknown.classList.add('asset-unknown');

decorateBlockText(copy, textDefault);
decorateBlockText(copy, textDefault, 'hasDetailHeading');
await decorateLockupFromContent(copy);
extendButtonsClass(copy);

Expand Down
3 changes: 2 additions & 1 deletion libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ export function decorateIconArea(el) {
}

export function decorateBlockText(el, config = ['m', 's', 'm'], type = null) {
const headings = el.querySelectorAll('h1, h2, h3, h4, h5, h6');
let headings = el.querySelectorAll('h1, h2, h3, h4, h5, h6');
if (!el.classList.contains('default')) {
if (headings) {
if (type === 'hasDetailHeading' && headings.length > 1) headings = [...headings].splice(1);
headings.forEach((h) => h.classList.add(`heading-${config[0]}`));
if (config[2]) {
const prevSib = headings[0]?.previousElementSibling;
Expand Down

0 comments on commit 8ea4f29

Please sign in to comment.