diff --git a/src/elements/core/styles/core.scss b/src/elements/core/styles/core.scss
index fea33f6988..d06d39faca 100644
--- a/src/elements/core/styles/core.scss
+++ b/src/elements/core/styles/core.scss
@@ -266,8 +266,9 @@ sbb-teaser :is(sbb-image, img) {
}
img {
- width: 100%;
display: block;
+ align-self: stretch;
+ width: 100%;
}
}
diff --git a/src/elements/teaser-hero/teaser-hero.scss b/src/elements/teaser-hero/teaser-hero.scss
index 8f7c96b17f..23326118a1 100644
--- a/src/elements/teaser-hero/teaser-hero.scss
+++ b/src/elements/teaser-hero/teaser-hero.scss
@@ -19,9 +19,13 @@
}
}
+::slotted([slot='image']) {
+ width: 100%;
+}
+
.sbb-teaser-hero {
position: relative;
- display: block;
+ display: flex;
min-height: var(--sbb-panel-height);
text-decoration: none;
diff --git a/src/elements/teaser-hero/teaser-hero.visual.spec.ts b/src/elements/teaser-hero/teaser-hero.visual.spec.ts
index 5423b4eeee..38077cdc31 100644
--- a/src/elements/teaser-hero/teaser-hero.visual.spec.ts
+++ b/src/elements/teaser-hero/teaser-hero.visual.spec.ts
@@ -2,7 +2,6 @@ import { html } from 'lit';
import {
describeViewports,
- loadAssetAsBase64,
visualDiffDefault,
visualDiffFocus,
visualDiffHover,
@@ -13,38 +12,61 @@ import '../image.js';
import '../chip-label.js';
const imageUrl = import.meta.resolve('../core/testing/assets/placeholder-image.png');
-const imageBase64 = await loadAssetAsBase64(imageUrl);
+
+const imgTestCases = [
+ {
+ title: 'with sbb-image',
+ imgSelector: 'sbb-image',
+ imgTemplate: () => html``,
+ },
+ {
+ title: 'with img tag',
+ imgSelector: 'img',
+ imgTemplate: () => html``,
+ },
+ {
+ title: 'with figure_sbb-image',
+ imgSelector: 'sbb-image',
+ imgTemplate: () =>
+ html``,
+ },
+ {
+ title: 'with figure_img',
+ imgSelector: 'img',
+ imgTemplate: () =>
+ html``,
+ },
+];
describe(`sbb-teaser-hero`, () => {
describeViewports({ viewports: ['zero', 'micro', 'small', 'medium', 'wide'] }, () => {
for (const state of [visualDiffDefault, visualDiffHover, visualDiffFocus]) {
- it(
- state.name,
- state.with(async (setup) => {
- await setup.withFixture(html`
-
- Break out and explore castles and palaces.
-
-
-
- `);
+ for (const testCase of imgTestCases) {
+ it(
+ `${testCase.title} ${state.name}`,
+ visualDiffDefault.with(async (setup) => {
+ await setup.withFixture(html`
+
+ Break out and explore castles and palaces. ${testCase.imgTemplate()}
+
+ `);
- await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
- }),
- );
+ await waitForImageReady(setup.snapshotElement.querySelector(testCase.imgSelector)!);
+ }),
+ );
+ }
it(
- `slotted ${state.name}`,
+ `without content ${state.name}`,
state.with(async (setup) => {
await setup.withFixture(html`
- Break out and explore castles and palaces.
- Find out more
`);
@@ -52,32 +74,21 @@ describe(`sbb-teaser-hero`, () => {
await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
}),
);
+ }
+ });
+ describeViewports({ viewports: ['large'] }, () => {
+ for (const testCase of imgTestCases) {
it(
- `slotted-image ${state.name}`,
- state.with(async (setup) => {
- await setup.withFixture(html`
-
- Break out and explore castles and palaces.
- Find out more
-
-
- `);
-
- await waitForImageReady(setup.snapshotElement.querySelector('img')!);
- }),
- );
-
- it(
- `without content ${state.name}`,
- state.with(async (setup) => {
+ `custom width ${testCase.title}`,
+ visualDiffDefault.with(async (setup) => {
await setup.withFixture(html`
-
-
+
+ Break out and explore castles and palaces. ${testCase.imgTemplate()}
`);
- await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
+ await waitForImageReady(setup.snapshotElement.querySelector(testCase.imgSelector)!);
}),
);
}