From 99cf963cfaeb97d63150fc81a5d4fa1f05de52b6 Mon Sep 17 00:00:00 2001 From: Marco D'Auria Date: Fri, 24 May 2024 12:00:29 +0200 Subject: [PATCH] fix: review --- .../__snapshots__/step-label.spec.snap.js | 76 +++++++++++++------ .../stepper/step-label/step-label.spec.ts | 54 ++++--------- src/components/stepper/step/step.scss | 3 +- .../stepper/stepper/stepper.stories.ts | 4 + src/components/stepper/stepper/stepper.ts | 1 + 5 files changed, 76 insertions(+), 62 deletions(-) diff --git a/src/components/stepper/step-label/__snapshots__/step-label.spec.snap.js b/src/components/stepper/step-label/__snapshots__/step-label.spec.snap.js index 302755c255..be67161c04 100644 --- a/src/components/stepper/step-label/__snapshots__/step-label.spec.snap.js +++ b/src/components/stepper/step-label/__snapshots__/step-label.spec.snap.js @@ -1,7 +1,22 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["sbb-step-label renders"] = +snapshots["sbb-step-label renders - Dom"] = +` + Label + +`; +/* end snapshot sbb-step-label renders - Dom */ + +snapshots["sbb-step-label renders - ShadomDom"] = `
@@ -13,9 +28,25 @@ snapshots["sbb-step-label renders"] =
`; -/* end snapshot sbb-step-label renders collapsed */ +/* end snapshot sbb-step-label renders - ShadomDom */ -snapshots["sbb-step-label renders with icon"] = +snapshots["sbb-step-label renders with icon - Dom"] = +` + Label + +`; +/* end snapshot sbb-step-label renders with icon - Dom */ + +snapshots["sbb-step-label renders with icon - ShadowDom"] = `
@@ -34,9 +65,26 @@ snapshots["sbb-step-label renders with icon"] =
`; -/* end snapshot sbb-step-label renders with icon" */ +/* end snapshot sbb-step-label renders with icon - ShadowDom */ + +snapshots["sbb-step-label renders disabled - Dom"] = +` + Label + +`; +/* end snapshot sbb-step-label renders disabled - Dom */ -snapshots["sbb-step-label renders disabled"] = +snapshots["sbb-step-label renders disabled - ShadowDom"] = `
@@ -48,7 +96,7 @@ snapshots["sbb-step-label renders disabled"] =
`; -/* end snapshot sbb-step-label renders disabled" */ +/* end snapshot sbb-step-label renders disabled - ShadowDom */ snapshots["sbb-step-label A11y tree Chrome"] = `

@@ -82,19 +130,3 @@ snapshots["sbb-step-label A11y tree Firefox"] = `; /* end snapshot sbb-step-label A11y tree Firefox */ -snapshots["sbb-step-label A11y tree Safari"] = -`

- { - "role": "WebArea", - "name": "", - "children": [ - { - "role": "tab", - "name": "Label" - } - ] -} -

-`; -/* end snapshot sbb-step-label A11y tree Safari */ - diff --git a/src/components/stepper/step-label/step-label.spec.ts b/src/components/stepper/step-label/step-label.spec.ts index 7e0987298f..e273115dad 100644 --- a/src/components/stepper/step-label/step-label.spec.ts +++ b/src/components/stepper/step-label/step-label.spec.ts @@ -6,57 +6,33 @@ import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; import './step-label.js'; describe('sbb-step-label', () => { - it('renders', async () => { + it('renders - Dom', async () => { const root = await fixture(html`Label`); + await expect(root).dom.to.be.equalSnapshot(); + }); - expect(root).dom.to.be.equal(` - Label - `); + it('renders - ShadomDom', async () => { + const root = await fixture(html`Label`); await expect(root).shadowDom.to.be.equalSnapshot(); }); - it('renders with icon', async () => { + it('renders with icon - Dom', async () => { const root = await fixture(html`Label`); + await expect(root).dom.to.be.equalSnapshot(); + }); - expect(root).dom.to.be.equal(` - Label - `); + it('renders with icon - ShadowDom', async () => { + const root = await fixture(html`Label`); await expect(root).shadowDom.to.be.equalSnapshot(); }); - it('renders disabled', async () => { + it('renders disabled - Dom', async () => { const root = await fixture(html`Label`); + await expect(root).dom.to.be.equalSnapshot(); + }); - expect(root).dom.to.be.equal(` - Label - `); + it('renders disabled - ShadowDom', async () => { + const root = await fixture(html`Label`); await expect(root).shadowDom.to.be.equalSnapshot(); }); diff --git a/src/components/stepper/step/step.scss b/src/components/stepper/step/step.scss index f8b84230ea..2877b40af0 100644 --- a/src/components/stepper/step/step.scss +++ b/src/components/stepper/step/step.scss @@ -11,6 +11,7 @@ --sbb-step-height: 0; --sbb-step-animation-duration: var(--sbb-animation-duration-2x); --sbb-step-animation-delay: 0; + --sbb-step-color: var(--sbb-color-iron); display: contents; position: relative; @@ -57,7 +58,7 @@ opacity: var(--sbb-step-opacity); visibility: var(--sbb-step-visibility); height: var(--sbb-step-height); - color: var(--sbb-color-iron); + color: var(--sbb-step-color); transition: { property: opacity, visibility; duration: var(--sbb-step-animation-duration); diff --git a/src/components/stepper/stepper/stepper.stories.ts b/src/components/stepper/stepper/stepper.stories.ts index 3dd3f877dc..5e53ac3415 100644 --- a/src/components/stepper/stepper/stepper.stories.ts +++ b/src/components/stepper/stepper/stepper.stories.ts @@ -90,6 +90,8 @@ const WithSingleFormTemplate = (args: Args): TemplateResult => { } }} @reset=${() => { + // This is needed to focus and trigger again the error on the first field + // when getting back to it after resetting the stepper. setTimeout(() => document.querySelector('input[name="name"]')?.dispatchEvent(new Event('input')), ); @@ -207,6 +209,8 @@ const WithMultipleFormsTemplate = (args: Args): TemplateResult => {
{ + // This is needed to focus and trigger again the error on the first field + // when getting back to it after resetting the stepper. setTimeout(() => document.querySelector('input[name="name"]')?.dispatchEvent(new Event('input')), ); diff --git a/src/components/stepper/stepper/stepper.ts b/src/components/stepper/stepper/stepper.ts index fab3b3999a..b2d9e4f91e 100644 --- a/src/components/stepper/stepper/stepper.ts +++ b/src/components/stepper/stepper/stepper.ts @@ -219,6 +219,7 @@ export class SbbStepperElement extends LitElement { this.orientation = isBreakpoint(this.horizontalFrom) ? 'horizontal' : 'vertical'; this._updateLabels(); } + // The timeout is needed to make sure that the marker takes the correct step-label size. setTimeout(() => this._setMarkerSize(), 0); }