fix: add newsletter box

This commit is contained in:
Tim Rijkse
2026-01-15 15:28:14 +01:00
parent 968d2036b4
commit 1a6b47c8d3
9 changed files with 313 additions and 8 deletions

View File

@@ -15,10 +15,37 @@ class PushBox extends HTMLElement {
connectedCallback() {
this.render();
// Use requestAnimationFrame to ensure slots are assigned
requestAnimationFrame(() => {
this.updateLogoVisibility();
});
}
attributeChangedCallback() {
this.render();
requestAnimationFrame(() => {
this.updateLogoVisibility();
});
}
updateLogoVisibility() {
const logoSlot = this.shadowRoot?.querySelector('slot[name="logo"]');
const logoWrapper = this.shadowRoot?.querySelector(".logo-wrapper");
if (logoSlot && logoWrapper) {
const assignedNodes = logoSlot.assignedNodes();
const hasContent =
assignedNodes.length > 0 &&
assignedNodes.some((node) => {
return node.nodeType === Node.ELEMENT_NODE && node.tagName === "IMG";
});
if (!hasContent) {
logoWrapper.classList.add("hidden");
} else {
logoWrapper.classList.remove("hidden");
}
}
}
get backgroundColor() {
@@ -53,6 +80,10 @@ class PushBox extends HTMLElement {
margin-bottom: 32px;
}
.logo-wrapper.hidden {
display: none;
}
.logo-wrapper ::slotted(img) {
width: 104px;
height: auto;
@@ -73,6 +104,12 @@ class PushBox extends HTMLElement {
font-size: 16px;
font-weight: 400;
}
.cta-wrapper ::slotted(.cta-buttons) {
display: flex;
gap: 16px;
flex-wrap: wrap;
}
</style>
<div class="push-box">
<div class="logo-wrapper">