Enforce equal notification card widths across wrapped rows

This commit is contained in:
2026-06-01 16:39:24 +02:00
parent 75a7d6d4ca
commit 4f77f08cba
2 changed files with 39 additions and 0 deletions
+34
View File
@@ -60,5 +60,39 @@
</div> </div>
</section> </section>
<script>
const updateNotificationsPatternRowState = () => {
document.querySelectorAll('.sg-notifications-pattern').forEach((grid) => {
const cards = Array.from(grid.querySelectorAll('.sg-notifications-pattern__card'));
grid.classList.remove('sg-notifications-pattern--multi-row');
grid.style.removeProperty('--layout-object-card-shared-width');
if (cards.length <= 1) {
return;
}
const firstTop = cards[0].offsetTop;
const hasMultipleRows = cards.some((card) => card.offsetTop !== firstTop);
if (!hasMultipleRows) {
return;
}
const firstRowCards = cards.filter((card) => card.offsetTop === firstTop);
const referenceCard = firstRowCards[0];
if (!referenceCard) {
return;
}
const referenceWidth = referenceCard.getBoundingClientRect().width;
grid.style.setProperty('--layout-object-card-shared-width', `${referenceWidth}px`);
grid.classList.add('sg-notifications-pattern--multi-row');
});
};
window.addEventListener('load', updateNotificationsPatternRowState);
window.addEventListener('resize', updateNotificationsPatternRowState);
</script>
</body> </body>
</html> </html>
+5
View File
@@ -16,6 +16,11 @@
max-width: var(--layout-object-card-max-width); max-width: var(--layout-object-card-max-width);
} }
.sg-notifications-pattern.sg-notifications-pattern--multi-row .sg-notifications-pattern__card {
flex: 0 0 var(--layout-object-card-shared-width);
width: var(--layout-object-card-shared-width);
}
.sg-notifications-pattern__text-segment { .sg-notifications-pattern__text-segment {
height: 200px; height: 200px;
} }