Skip to content

Commit

Permalink
feat(sbb-container): support background-expanded for images (#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Aug 21, 2024
1 parent 68d8f2c commit 298b335
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
10 changes: 7 additions & 3 deletions src/elements/container/container/container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -45,7 +49,7 @@
@include sbb.page-spacing-expanded;
}

:host([data-slot-names~='image']) & {
:host([data-slot-names~='image']:not([background-expanded])) & {
position: relative;
}
}
Expand All @@ -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);

Expand Down
51 changes: 37 additions & 14 deletions src/elements/container/container/container.visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<sbb-container ?background-expanded=${backgroundExpanded}>
${containerContent()}
</sbb-container>
`,
{ backgroundColor: 'var(--sbb-color-silver)', padding: '0' },
);
}),
);
it(
``,
visualDiffDefault.with(async (setup) => {
await setup.withFixture(
html`
<sbb-container ?background-expanded=${backgroundExpanded}>
${containerContent()}
</sbb-container>
`,
wrapperStyles,
);

await setViewport(viewport);
}),
);

it(
`background-image`,
visualDiffDefault.with(async (setup) => {
await setup.withFixture(
html`
<sbb-container ?background-expanded=${backgroundExpanded}>
${backgroundImageContent}
<sbb-image slot="image" image-src=${imageUrl}></sbb-image>
</sbb-container>
`,
wrapperStyles,
);

await setViewport(viewport);
await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
}),
);
});
}
});

0 comments on commit 298b335

Please sign in to comment.