From 298b3352e42966747237d043690a90671987faa0 Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Wed, 21 Aug 2024 11:50:58 +0200 Subject: [PATCH] feat(sbb-container): support background-expanded for images (#3004) --- .../container/container/container.scss | 10 ++-- .../container/container.visual.spec.ts | 51 ++++++++++++++----- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/elements/container/container/container.scss b/src/elements/container/container/container.scss index bedbbc73ab..8a6ad3ca9a 100644 --- a/src/elements/container/container/container.scss +++ b/src/elements/container/container/container.scss @@ -20,10 +20,14 @@ --sbb-container-padding: var(--sbb-spacing-responsive-xxl); } -:host(:not([expanded])[background-expanded]) { +:host([background-expanded]:not([expanded])) { background-color: var(--sbb-container-background-color); } +:host([data-slot-names~='image'][background-expanded]) { + position: relative; +} + .sbb-container { background-color: var(--sbb-container-background-color); padding: var(--sbb-container-padding); @@ -45,7 +49,7 @@ @include sbb.page-spacing-expanded; } - :host([data-slot-names~='image']) & { + :host([data-slot-names~='image']:not([background-expanded])) & { position: relative; } } @@ -60,7 +64,7 @@ position: absolute; inset: 0; - :host(:not([expanded])) & { + :host(:not([expanded], [background-expanded])) & { @include sbb.mq($from: ultra) { --sbb-image-border-radius: var(--sbb-border-radius-4x); diff --git a/src/elements/container/container/container.visual.spec.ts b/src/elements/container/container/container.visual.spec.ts index 0eabd08d32..d95e6344d7 100644 --- a/src/elements/container/container/container.visual.spec.ts +++ b/src/elements/container/container/container.visual.spec.ts @@ -126,20 +126,43 @@ describe(`sbb-container`, () => { // Test very large screens for (const backgroundExpanded of backgroundExpandedCases) { - it( - `viewport=custom_background-expanded=${backgroundExpanded}`, - visualDiffDefault.with(async (setup) => { - await setViewport({ width: SbbBreakpointUltraMin + 300, height: 600 }); + describe(`viewport=custom_background-expanded=${backgroundExpanded}`, () => { + const viewport = { width: SbbBreakpointUltraMin + 300, height: 600 }; + const wrapperStyles = { backgroundColor: 'var(--sbb-color-silver)', padding: '0' }; - await setup.withFixture( - html` - - ${containerContent()} - - `, - { backgroundColor: 'var(--sbb-color-silver)', padding: '0' }, - ); - }), - ); + it( + ``, + visualDiffDefault.with(async (setup) => { + await setup.withFixture( + html` + + ${containerContent()} + + `, + wrapperStyles, + ); + + await setViewport(viewport); + }), + ); + + it( + `background-image`, + visualDiffDefault.with(async (setup) => { + await setup.withFixture( + html` + + ${backgroundImageContent} + + + `, + wrapperStyles, + ); + + await setViewport(viewport); + await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!); + }), + ); + }); } });