diff --git a/src/elements/container/container/container.scss b/src/elements/container/container/container.scss
index 27b441d9eb..0950dc6905 100644
--- a/src/elements/container/container/container.scss
+++ b/src/elements/container/container/container.scss
@@ -4,6 +4,8 @@
@include sbb.box-sizing;
:host {
+ --sbb-container-background-border-radius: 0;
+
display: block;
}
@@ -28,6 +30,12 @@
position: relative;
}
+:host(:not([expanded], [background-expanded])) {
+ @include sbb.mq($from: ultra) {
+ --sbb-container-background-border-radius: var(--sbb-border-radius-4x);
+ }
+}
+
.sbb-container {
background-color: var(--sbb-container-background-color);
padding: var(--sbb-container-padding);
@@ -62,22 +70,8 @@
}
::slotted([slot='image']) {
- --sbb-image-border-radius: 0;
-
position: absolute;
inset: 0;
-
- :host(:not([expanded], [background-expanded])) & {
- @include sbb.mq($from: ultra) {
- --sbb-image-border-radius: var(--sbb-border-radius-4x);
-
- border-radius: var(--sbb-border-radius-4x);
- }
- }
-}
-
-::slotted(img[slot='image']) {
- object-fit: cover;
height: 100%;
width: 100%;
}
diff --git a/src/elements/container/container/container.visual.spec.ts b/src/elements/container/container/container.visual.spec.ts
index d95e6344d7..da75e666c8 100644
--- a/src/elements/container/container/container.visual.spec.ts
+++ b/src/elements/container/container/container.visual.spec.ts
@@ -11,6 +11,7 @@ import { waitForImageReady } from '../../core/testing.js';
import '../../button.js';
import '../../card.js';
+import '../../chip-label.js';
import '../../image.js';
import '../../title.js';
import './container.js';
@@ -25,10 +26,20 @@ describe(`sbb-container`, () => {
const images = [
{
+ name: 'sbb-image',
selector: 'sbb-image',
image: html``,
},
{
+ name: 'figure-sbb-image',
+ selector: 'sbb-image',
+ image: html``,
+ },
+ {
+ name: 'img',
selector: 'img',
image: html` {
alt=''
>`,
},
+ {
+ name: 'figure-img',
+ selector: 'img',
+ image: html``,
+ },
];
const containerContent = (): TemplateResult => html`
@@ -88,7 +107,7 @@ describe(`sbb-container`, () => {
describe(`expanded=${expanded}`, () => {
for (const image of images) {
it(
- `slotted=${image.selector}`,
+ `slotted=${image.name}`,
visualDiffDefault.with(async (setup) => {
await setup.withFixture(
html`
@@ -146,23 +165,24 @@ describe(`sbb-container`, () => {
}),
);
- it(
- `background-image`,
- visualDiffDefault.with(async (setup) => {
- await setup.withFixture(
- html`
-
- ${backgroundImageContent}
-
-
- `,
- wrapperStyles,
- );
+ for (const image of images) {
+ it(
+ `background-image slotted=${image.name}`,
+ visualDiffDefault.with(async (setup) => {
+ await setup.withFixture(
+ html`
+
+ ${backgroundImageContent} ${image.image}
+
+ `,
+ wrapperStyles,
+ );
- await setViewport(viewport);
- await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
- }),
- );
+ await setViewport(viewport);
+ await waitForImageReady(setup.snapshotElement.querySelector(image.selector)!);
+ }),
+ );
+ }
});
}
});
diff --git a/src/elements/container/container/readme.md b/src/elements/container/container/readme.md
index e5a7cc9f83..3bb1543a81 100644
--- a/src/elements/container/container/readme.md
+++ b/src/elements/container/container/readme.md
@@ -19,6 +19,21 @@ use CSS object-position for slotted `img`, or `--sbb-image-object-position` vari
If an image is present, the container receives a pre-defined padding.
It's possible to override the padding by using the CSS variable `--sbb-container-padding`.
+Optionally, you can add an overlapping `sbb-chip-label` by wrapping the `sbb-image` in a `figure` tag (see [sbb-image doc](/docs/elements-sbb-image--docs#utility%classes)).
+
+```html
+
+
+ ...
+
+```
+
## Style
By default `sbb-container` uses the `page spacing` defined in the [layout documentation](/docs/styles-layout--docs). Optionally the user can use the `expanded` property (default: `false`) to switch to the `page spacing expanded` layout.
diff --git a/src/elements/core/styles/_index.scss b/src/elements/core/styles/_index.scss
index db8fac890e..568231e357 100644
--- a/src/elements/core/styles/_index.scss
+++ b/src/elements/core/styles/_index.scss
@@ -9,6 +9,7 @@
@forward './mixins/chip';
@forward './mixins/font-face';
@forward './mixins/helpers';
+@forward './mixins/image';
@forward './mixins/inputs';
@forward './mixins/layout';
@forward './mixins/link';
diff --git a/src/elements/core/styles/core.scss b/src/elements/core/styles/core.scss
index 89284eb0ec..220a7f68e3 100644
--- a/src/elements/core/styles/core.scss
+++ b/src/elements/core/styles/core.scss
@@ -154,6 +154,121 @@ input[data-sbb-time-input] {
}
}
+img {
+ aspect-ratio: var(--sbb-image-aspect-ratio);
+ object-fit: var(--sbb-image-object-fit);
+ object-position: var(--sbb-image-object-position);
+}
+
+// TODO: Move back to the sbb-container components when the global css refactoring happens
+sbb-container {
+ [slot='image']:is(sbb-image, img),
+ [slot='image'] :is(sbb-image, img) {
+ --sbb-image-object-fit: cover;
+
+ border-radius: var(--sbb-container-background-border-radius);
+ height: 100%;
+ position: absolute;
+ }
+}
+
+// TODO: Move back to the sbb-flip-card-summary components when the global css refactoring happens
+sbb-flip-card-summary {
+ [slot='image']:is(sbb-image, img),
+ [slot='image'] :is(sbb-image, img) {
+ --sbb-image-aspect-ratio: auto;
+ --sbb-image-object-fit: cover;
+
+ border-radius: 0;
+ display: block;
+ height: 100%;
+ }
+}
+
+// TODO: Move back to the sbb-lead-container components when the global css refactoring happens
+sbb-lead-container {
+ [slot='image']:is(sbb-image, img, picture),
+ [slot='image'] :is(sbb-image, img, picture) {
+ --sbb-image-aspect-ratio: var(--sbb-lead-container-image-ratio);
+ --sbb-image-object-fit: cover;
+
+ border-radius: var(--sbb-lead-container-image-border-radius);
+ }
+}
+
+// Target the slotted `sbb-image` which are generally wrapped by a
Content
diff --git a/src/elements/teaser-product/teaser-product-static/readme.md b/src/elements/teaser-product/teaser-product-static/readme.md
index 554f896ea4..ff73fa8ea5 100644
--- a/src/elements/teaser-product/teaser-product-static/readme.md
+++ b/src/elements/teaser-product/teaser-product-static/readme.md
@@ -15,15 +15,21 @@ otherwise, see [sbb-teaser-product](/docs/elements-sbb-teaser-sbb-teaser-product
## Slots
-Use the `image` slot to pass a `sbb-image` or an `img` that will be used as a background,
-and use the optional `footnote` slot to add a text anchored to the bottom-end of the component.
+Use the `image` slot to pass an `sbb-image` or an `img` that will be used as background.
+Optionally, you can add an overlapping `sbb-chip-label` by wrapping the `sbb-image` in a `figure` tag (see [sbb-image doc](/docs/elements-sbb-image--docs#utility%classes)).
+
+Use the optional `footnote` slot to add a text anchored to the bottom-end of the component.
The default slot is reserved for the main content: it could be a simple text or a text combined with more elements,
like a `sbb-title` or some interactive elements, like buttons or links within the `sbb-action-group` component.
```html
-
+
+
+ Chip label
+
+
diff --git a/src/elements/teaser-product/teaser-product/readme.md b/src/elements/teaser-product/teaser-product/readme.md
index 6166250124..6d170b7953 100644
--- a/src/elements/teaser-product/teaser-product/readme.md
+++ b/src/elements/teaser-product/teaser-product/readme.md
@@ -16,15 +16,21 @@ If it has to include more than one interactive element, use the [sbb-teaser-prod
## Slots
-Use the `image` slot to pass a `sbb-image` or an `img` that will be used as a background,
-and use the optional `footnote` slot to add a text anchored to the bottom-end of the component.
+Use the `image` slot to pass an `sbb-image` or an `img` that will be used as background.
+Optionally, you can add an overlapping `sbb-chip-label` by wrapping the `sbb-image` in a `figure` tag (see [sbb-image doc](/docs/elements-sbb-image--docs#utility%classes)).
+
+Use the optional `footnote` slot to add a text anchored to the bottom-end of the component.
The default slot is reserved for the main content: it could be a simple text or a text combined with more elements,
like the `sbb-title` or an interactive element, like a button or a link (needs to be in static variant!).
```html
-
+
+
+ Chip label
+
+