Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sbb-container): support background-expanded for images #3004

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')!);
}),
);
});
}
});
Loading