Skip to content

Commit

Permalink
style wrappers when no nested elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartxi authored and overmyheadandbody committed Nov 6, 2024
1 parent f12d8ec commit 46dad6c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ export function decorateBlockText(el, config = ['m', 's', 'm'], type = null) {
decorateIconArea(el);
}
}
const bodyDefault = `body-${config[1]}`;
const emptyEls = el.querySelectorAll('p:not([class]), ul:not([class]), ol:not([class])');
if (emptyEls.length) {
emptyEls.forEach((p) => p.classList.add(`body-${config[1]}`));
emptyEls.forEach((p) => p.classList.add(bodyDefault));
} else {
[...el.querySelectorAll('div:not([class])')]
.filter((emptyDivs) => emptyDivs.textContent.trim() !== '')
.forEach((text) => text.classList.add(`body-${config[1]}`));
const emptyDivs = el.querySelectorAll('div:not([class])');
if (emptyDivs.length) {
[...emptyDivs].filter((div) => div.textContent.trim() !== '').forEach((text) => {
text.classList.add(bodyDefault);
});
} else if (!el.classList.length) {
el.classList.add(bodyDefault);
}
}
}
const buttonSize = config.length > 3 ? `button-${config[3]}` : '';
Expand Down

0 comments on commit 46dad6c

Please sign in to comment.