From 18a54a20e5e73ece56353c44172356fb61afe053 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Tue, 13 Aug 2024 15:53:22 +0200 Subject: [PATCH] fix(sbb-flip-card): support disabled animation --- .../flip-card/flip-card/flip-card.scss | 19 ++++++--- .../flip-card/flip-card.visual.spec.ts | 39 ++++++++++--------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/elements/flip-card/flip-card/flip-card.scss b/src/elements/flip-card/flip-card/flip-card.scss index 7e99f47c96..a6b5ca59ea 100644 --- a/src/elements/flip-card/flip-card/flip-card.scss +++ b/src/elements/flip-card/flip-card/flip-card.scss @@ -9,10 +9,16 @@ --sbb-flip-card-border-radius: var(--sbb-border-radius-4x); --sbb-flip-card-min-height: #{sbb.px-to-rem-build(280)}; --sbb-flip-card-details-min-height: var(--sbb-flip-card-min-height); - --sbb-flip-card-summary-transition-duration: var(--sbb-animation-duration-5x); + --sbb-flip-card-summary-transition-duration: var( + --sbb-disable-animation-zero-time, + var(--sbb-animation-duration-5x) + ); --sbb-flip-card-summary-transition-delay: var(--sbb-animation-duration-2x); - --sbb-flip-card-details-transition-duration: var(--sbb-animation-duration-4x); - --sbb-flip-card-details-transition-delay: var(--sbb-disable-animation-zero-time); + --sbb-flip-card-details-transition-duration: var( + --sbb-disable-animation-zero-time, + var(--sbb-animation-duration-4x) + ); + --sbb-flip-card-details-transition-delay: 0s; position: relative; display: block; @@ -28,9 +34,12 @@ :host([data-flipped]) { --sbb-flip-card-background-color: var(--sbb-color-midnight); - --sbb-flip-card-details-transition-duration: var(--sbb-animation-duration-2x); + --sbb-flip-card-details-transition-duration: var( + --sbb-disable-animation-zero-time, + var(--sbb-animation-duration-2x) + ); --sbb-flip-card-details-transition-delay: var(--sbb-animation-duration-5x); - --sbb-flip-card-summary-transition-delay: var(--sbb-disable-animation-zero-time); + --sbb-flip-card-summary-transition-delay: 0s; --sbb-flip-card-details-min-height: fit-content; ::slotted(sbb-flip-card-summary) { diff --git a/src/elements/flip-card/flip-card/flip-card.visual.spec.ts b/src/elements/flip-card/flip-card/flip-card.visual.spec.ts index 689d4a9916..37d1c82050 100644 --- a/src/elements/flip-card/flip-card/flip-card.visual.spec.ts +++ b/src/elements/flip-card/flip-card/flip-card.visual.spec.ts @@ -21,7 +21,7 @@ const content = ( imageAlignment: SbbFlipCardImageAlignment = 'after', longContent: boolean = false, ): TemplateResult => - html` + html` ${title} - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam luctus ornare condimentum. + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam luctus ornare condimentum. Vivamus turpis elit, dapibus eget fringilla pellentesque, lobortis in nibh. ${longContent ? `Duis dapibus vitae @@ -42,25 +42,28 @@ const content = ( luctus ornare condimentum. Vivamus turpis elit, dapibus eget fringilla pellentesque, lobortis in nibh. Duis dapibus vitae tortor ullamcorper maximus. In convallis consectetur felis.` : nothing} - Link`; + Link + `; describe(`sbb-flip-card`, () => { describeViewports({ viewports: ['zero', 'medium'] }, () => { for (const imageAlignment of ['after', 'below']) { - for (const state of [visualDiffDefault, visualDiffFocus]) { - it( - `image-alignment=${imageAlignment} ${state.name}`, - state.with(async (setup) => { - await setup.withFixture(html` - - ${content('Summary', imageAlignment as SbbFlipCardImageAlignment)} - - `); - await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!); - }), - ); - } + describe(`image-alignment=${imageAlignment}`, () => { + for (const state of [visualDiffDefault, visualDiffFocus]) { + it( + state.name, + state.with(async (setup) => { + await setup.withFixture(html` + + ${content('Summary', imageAlignment as SbbFlipCardImageAlignment)} + + `); + + await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!); + }), + ); + } + }); } it(