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-stepper): introduce sbb-stepper component #2491

Merged
merged 107 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
8cb7743
feat: generate components
dauriamarco Mar 13, 2024
cfb5c31
feat: step-label first implementation
dauriamarco Mar 13, 2024
c7e69b5
feat: sbb-stepper first implementation
dauriamarco Mar 13, 2024
ffa5e51
feat: add stepper marker
dauriamarco Mar 14, 2024
1ae8cd8
feat: add validate event custom type
dauriamarco Mar 14, 2024
1d9d0b0
feat: add vertical variant
dauriamarco Mar 14, 2024
a6d2a31
fix: step label style
dauriamarco Mar 14, 2024
0ef56a6
fix: temp disable tests
dauriamarco Mar 14, 2024
e0fa6f0
fix(docs-generate): fix generation when component has no attributes
TomMenga Mar 14, 2024
0234e9f
fix: hostAttributes order
dauriamarco Mar 14, 2024
6843ff9
feat: add step label focus outline
dauriamarco Mar 14, 2024
2820ae6
feat: add initial selected index
dauriamarco Mar 14, 2024
8f45335
refactor: use internals to set aria attributes
dauriamarco Mar 14, 2024
0afdd12
feat: implement horizontalFrom
dauriamarco Mar 14, 2024
26753b8
fix: horizontalFrom logic
dauriamarco Mar 14, 2024
c190c38
feat: add animations
dauriamarco Mar 15, 2024
326d577
fix: update labels with horizontalFrom
dauriamarco Mar 15, 2024
29b96af
feat: add long labels
dauriamarco Mar 15, 2024
487ada5
feat: react to labels slotchange
dauriamarco Mar 15, 2024
7994396
feat: add reset method
dauriamarco Mar 15, 2024
fa9ee26
feat: always reset the form programmatically
dauriamarco Mar 15, 2024
8181eca
test: add e2e and spec tests
dauriamarco Mar 15, 2024
ef50830
docs: add documentation
dauriamarco Mar 15, 2024
f024890
fix: tests
dauriamarco Mar 15, 2024
3d8c2db
fix: high contrast mode
dauriamarco Mar 16, 2024
9c8681b
feat: add disable-animation on init and resize
dauriamarco Mar 16, 2024
2fed339
fix: configure labels ariaSelected
dauriamarco Mar 16, 2024
02f6fef
fix: disable-animation on init
dauriamarco Mar 16, 2024
663a09f
fix: long labels on vertical orientation
dauriamarco Mar 16, 2024
5537da6
fix: tests
dauriamarco Mar 16, 2024
f7deaae
fix: validate event details type
dauriamarco Mar 18, 2024
f3682cf
fix: review
dauriamarco Mar 20, 2024
50c308c
fix: set ariaSelected on labels
dauriamarco Mar 21, 2024
e544ab2
fix: review
dauriamarco Apr 15, 2024
c3e9ca9
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Apr 15, 2024
9bc1b3e
fix: merge
dauriamarco Apr 15, 2024
4ce3923
fix: improve step configuration
dauriamarco Apr 17, 2024
897a361
fix: ui review
dauriamarco Apr 18, 2024
ca2aba7
fix: ui icon overflow
dauriamarco Apr 18, 2024
9af676d
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Apr 18, 2024
024bd87
fix: imports
dauriamarco Apr 18, 2024
d5bf592
fix: tests
dauriamarco Apr 18, 2024
8be9cfe
fix: marker size on safari
dauriamarco Apr 22, 2024
65d6133
fix: horizontal-from init
dauriamarco Apr 22, 2024
5fb59cd
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Apr 22, 2024
ba27a34
feat: add disabled step story
dauriamarco Apr 22, 2024
d866db3
fix: disable steps in linear mode
dauriamarco Apr 23, 2024
9ffcb62
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Apr 23, 2024
43beeed
fix: adapt stories
dauriamarco Apr 23, 2024
1328019
fix: adapt disable animation logic
dauriamarco Apr 23, 2024
1e89e14
fix: preserve init disable state
dauriamarco Apr 24, 2024
d3f198b
fix: margins and disabled on next
dauriamarco Apr 24, 2024
dab8661
fix: label spec test
dauriamarco Apr 24, 2024
8243bfc
fix: stories form errors
dauriamarco Apr 24, 2024
6834e90
feat: add slotted icon stories
dauriamarco Apr 24, 2024
dc2f121
fix: improve styles
dauriamarco Apr 24, 2024
c86d37d
fix: step resizer observer
dauriamarco Apr 24, 2024
59592be
fix: horizontal variant margin top
dauriamarco Apr 25, 2024
ee34c12
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 14, 2024
6f8485d
fix: integrity
dauriamarco May 14, 2024
719856a
fix: change linear mode
dauriamarco May 16, 2024
83cdb25
fix: tests
dauriamarco May 16, 2024
1b2f6ef
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 16, 2024
9361071
fix: review
dauriamarco May 24, 2024
ca1469c
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 24, 2024
99cf963
fix: review
dauriamarco May 24, 2024
af5ff23
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 27, 2024
6235a8e
feat: add arow navigation
dauriamarco May 27, 2024
94da7c3
fix: high contrast label colors
dauriamarco May 27, 2024
3835d98
fix: review
dauriamarco May 28, 2024
60a03fd
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 28, 2024
0071559
fix: review
dauriamarco May 28, 2024
d9ff754
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 28, 2024
6b04631
fix: review
dauriamarco May 28, 2024
d953ef9
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 28, 2024
68b955d
test: add e2e tests
dauriamarco May 28, 2024
25d3e88
fix: use card in stories
dauriamarco May 28, 2024
2821178
fix: review
dauriamarco May 29, 2024
da10d11
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 29, 2024
2d36948
Merge branch 'refs/heads/main' into feat/introduce-sbb-stepper
TomMenga May 30, 2024
1912a19
chore: update stories section
TomMenga May 30, 2024
1ee9c15
fix: accessibility
dauriamarco May 30, 2024
1ce4f2e
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco May 30, 2024
b4c59f9
fix: tests
dauriamarco May 30, 2024
a28d346
fix: review
dauriamarco Jun 3, 2024
c0f2902
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 3, 2024
ddfd6c0
fix: stepper stories
dauriamarco Jun 4, 2024
98a2922
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 4, 2024
a6a2f41
fix: review
dauriamarco Jun 4, 2024
fcb2f80
fix: improve tests
dauriamarco Jun 4, 2024
5446ba9
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 4, 2024
46c1c7a
test: add ssr tests
dauriamarco Jun 5, 2024
db58483
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 5, 2024
2d752be
fix: handle focus crrectly
dauriamarco Jun 5, 2024
0940a70
fix: improve tests
dauriamarco Jun 5, 2024
c8b8772
fix: accessibility
dauriamarco Jun 5, 2024
4a51130
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 5, 2024
e25714d
fix: tests
dauriamarco Jun 5, 2024
473da6f
fix: stories
dauriamarco Jun 5, 2024
7f27c6c
fix: review
dauriamarco Jun 6, 2024
f846f38
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 6, 2024
a2888ee
Update src/elements/stepper/step-label/readme.md
DavideMininni-Fincons Jun 6, 2024
879825c
Update src/elements/stepper/stepper/readme.md
DavideMininni-Fincons Jun 6, 2024
a6b0801
Update src/elements/stepper/step/readme.md
DavideMininni-Fincons Jun 6, 2024
025eac2
fix: rename dom and shadow dom
dauriamarco Jun 6, 2024
58ff0a3
fix: arrow navigation focus
dauriamarco Jun 6, 2024
c22aced
Merge remote-tracking branch 'origin/main' into feat/introduce-sbb-st…
dauriamarco Jun 6, 2024
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
14 changes: 14 additions & 0 deletions src/elements/core/styles/a11y.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@
.sbb-screen-reader-only {
@include a11y.screen-reader-only;
}

.sbb-focus-outline:focus-visible {
@include a11y.focus-outline;

border-radius: var(--sbb-border-radius-1x);
dauriamarco marked this conversation as resolved.
Show resolved Hide resolved
}

.sbb-focus-outline-dark:focus-visible {
@include a11y.focus-outline;

--sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);

border-radius: var(--sbb-border-radius-1x);
}
20 changes: 20 additions & 0 deletions src/elements/stepper/step-label/step-label.ssr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { assert } from '@open-wc/testing';
import { html } from 'lit';

import { fixture } from '../../core/testing/private.js';

import { SbbStepLabelElement } from './step-label.js';

describe(`sbb-step-label ${fixture.name}`, () => {
let root: SbbStepLabelElement;

beforeEach(async () => {
root = await fixture(html`<sbb-step-label>Label</sbb-step-label>`, {
modules: ['./step-label.js'],
});
});

it('renders', () => {
assert.instanceOf(root, SbbStepLabelElement);
});
});
5 changes: 1 addition & 4 deletions src/elements/stepper/step/__snapshots__/step.spec.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ snapshots["sbb-step renders - Dom"] =

snapshots["sbb-step renders - ShadowDom"] =
`<div class="sbb-step--wrapper">
<div
class="sbb-step"
tabindex="0"
>
<div class="sbb-step">
<slot>
</slot>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/elements/stepper/step/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Whenever a step switch is triggered, a `validate` event is emitted and can be ca

## Accessibility

Whenever textual content is provided, please also set the attribute `tabindex=‘0’` on the text tag, so that it can be reached and announced by screen-readers. Also remember to use the classes `.sbb-focus-outline` and `.sbb-focus-outline-dark` to correctly style the outline.

```html
<sbb-step>
<p tabindex="0" class="sbb-focus-outline">Step content</p>
<sbb-button>Button<sbb-button>
</sbb-step>
```

The aria attribute `aria-labelledby` is set automatically.

<!-- Auto Generated Below -->
Expand Down
6 changes: 0 additions & 6 deletions src/elements/stepper/step/step.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,4 @@
delay: var(--sbb-step-animation-delay);
timing-function: var(--sbb-animation-easing);
}

&:focus-visible {
@include sbb.focus-outline;

border-radius: var(--sbb-border-radius-1x);
}
}
18 changes: 18 additions & 0 deletions src/elements/stepper/step/step.ssr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { assert } from '@open-wc/testing';
import { html } from 'lit';

import { fixture } from '../../core/testing/private.js';

import { SbbStepElement } from './step.js';

describe(`sbb-step ${fixture.name}`, () => {
let root: SbbStepElement;

beforeEach(async () => {
root = await fixture(html`<sbb-step>Step</sbb-step>`, { modules: ['./step.js'] });
});

it('renders', () => {
assert.instanceOf(root, SbbStepElement);
});
});
1 change: 0 additions & 1 deletion src/elements/stepper/step/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export class SbbStepElement extends LitElement {
<div class="sbb-step--wrapper">
<div
class="sbb-step"
tabindex="0"
${ref((step) => step && this._stepResizeObserver.observe(step as HTMLElement))}
>
<slot></slot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ snapshots["sbb-stepper A11y tree Chrome"] =
"name": "Test step label 4"
},
{
"role": "generic",
"role": "text",
"name": "Test step content 1"
}
]
Expand Down Expand Up @@ -167,14 +167,8 @@ snapshots["sbb-stepper A11y tree Firefox"] =
"name": "4 Test step label 4"
},
{
"role": "section",
"name": "",
"children": [
{
"role": "text leaf",
"name": "Test step content 1"
}
]
"role": "text leaf",
"name": "Test step content 1"
},
{
"role": "tabpanel",
Expand Down
18 changes: 18 additions & 0 deletions src/elements/stepper/stepper/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ Whenever a step switch is triggered, a `validate` event is emitted and can be ca

## Accessibility

Whenever textual content is provided, please also set the attribute `tabindex=‘0’` on the text tag, so that it can be reached and announced by screen-readers. Also remember to use the classes `.sbb-focus-outline` and `.sbb-focus-outline-dark` to correctly style the outline.

```html
<sbb-stepper aria-label="Purpose of this flow">
<sbb-step-label>Step label 1</sbb-step-label>
<sbb-step>
<p tabindex="0" class="sbb-focus-outline">Step content 1</p>
<sbb-button>Button<sbb-button>
</sbb-step>

<sbb-step-label>Step label 2</sbb-step-label>
<sbb-step>
<p tabindex="0" class="sbb-focus-outline">Step content 2</p>
<sbb-button>Button<sbb-button>
</sbb-step>
</sbb-stepper>
```

Use an `aria-label` attribute to describe the purpose of the stepper. The `sbb-stepper` also sets other attributes on the steps and the step labels like `aria-setsize`, `aria-posinset`, `aria-controls`, `aria-labelledby`. If important content needs to be announced when a step is changed, use the `aria-live=‘polite’` attribute.

<!-- Auto Generated Below -->
Expand Down
19 changes: 14 additions & 5 deletions src/elements/stepper/stepper/stepper.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ describe('sbb-stepper', () => {
<sbb-stepper>
<sbb-step-label>Step 1</sbb-step-label>
<sbb-step>
Step one content.
<div tabindex="0" id="step-one-content"></div>Step one content.</div>
dauriamarco marked this conversation as resolved.
Show resolved Hide resolved
<button sbb-stepper-next id="next-button-1">Next</button>
</sbb-step>

<sbb-step-label>Step 2</sbb-step-label>
<sbb-step>
Step two content.
<div tabindex="0"></div>Step two content.</div>
<button sbb-stepper-next>Next</button>
<span sbb-stepper-previous>Back</span>
</sbb-step>

<sbb-step-label>Step 3</sbb-step-label>
<sbb-step>
Step three content.
<div tabindex="0"></div>Step three content.</div>
<span sbb-stepper-previous>Back</span>
</sbb-step>

<sbb-step-label disabled>Step 4</sbb-step-label>
<sbb-step> Step four content. </sbb-step>
<sbb-step> <div tabindex="0"></div>Step four content.</div> </sbb-step>
</sbb-stepper>
`);
});
Expand All @@ -61,13 +61,15 @@ describe('sbb-stepper', () => {
)!;
const validate = new EventSpy(SbbStepElement.events.validate);

stepLabelThree.focus();
stepLabelThree.click();
await waitForLitRender(element);

await waitForCondition(() => validate.events.length === 1);
expect(validate.count).to.be.equal(1);
expect(stepLabelThree).to.have.attribute('data-selected');
expect(stepLabelThree.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).to.be.equal(stepLabelThree.id);
});

it('selects the correct step via `selected` and emits validate event', async () => {
Expand All @@ -83,6 +85,7 @@ describe('sbb-stepper', () => {
expect(validate.count).to.be.equal(1);
expect(stepLabelThree).to.have.attribute('data-selected');
expect(stepLabelThree.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).not.to.be.equal(stepLabelThree.id);
});

it('selects the correct step via `selectedIndex` and emits validate event', async () => {
Expand All @@ -98,6 +101,7 @@ describe('sbb-stepper', () => {
expect(validate.count).to.be.equal(1);
expect(stepLabelThree).to.have.attribute('data-selected');
expect(stepLabelThree.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).not.to.be.equal(stepLabelThree.id);
});

it('selects the next step on [sbb-stepper-next] click and emits validate event', async () => {
Expand All @@ -107,13 +111,15 @@ describe('sbb-stepper', () => {
)!;
const validate = new EventSpy(SbbStepElement.events.validate);

stepperNext.focus();
stepperNext.click();
await waitForLitRender(element);

await waitForCondition(() => validate.events.length === 1);
expect(validate.count).to.be.equal(1);
expect(stepLabelTwo).to.have.attribute('data-selected');
expect(stepLabelTwo.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).to.be.equal(stepLabelTwo.id);
});

it('selects the previous step on [sbb-stepper-previous] click', async () => {
Expand All @@ -127,19 +133,22 @@ describe('sbb-stepper', () => {
)!;
const validate = new EventSpy(SbbStepElement.events.validate);

stepperNext.focus();
stepperNext.click();
await waitForLitRender(element);

await waitForCondition(() => validate.events.length === 1);
expect(validate.count).to.be.equal(1);
expect(stepLabelTwo).to.have.attribute('data-selected');
expect(stepLabelTwo.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).to.be.equal(stepLabelTwo.id);

stepperPrevious.click();
await waitForLitRender(element);

expect(stepLabelOne).to.have.attribute('data-selected');
expect(stepLabelOne.step).to.have.attribute('data-selected');
expect(document.activeElement!.id).to.be.equal(stepLabelOne.id);
});

it('selects only the next step via [sbb-stepper-next] click in linear mode and emits validate event', async () => {
Expand Down Expand Up @@ -304,7 +313,7 @@ describe('sbb-stepper', () => {
expect(document.activeElement!.id).to.be.equal(stepLabelOne.id);

await sendKeys({ down: 'Tab' });
expect(document.activeElement!.id).to.be.equal(stepLabelOne.step!.id);
expect(document.activeElement!.id).to.be.equal('step-one-content');
});

it('sets the correct aria-labelledby attributes', async () => {
Expand Down
34 changes: 34 additions & 0 deletions src/elements/stepper/stepper/stepper.ssr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { assert } from '@open-wc/testing';
import { html } from 'lit';

import { fixture } from '../../core/testing/private.js';

import { SbbStepperElement } from './stepper.js';

import '../step.js';
import '../step-label.js';

describe(`sbb-stepper ${fixture.name}`, () => {
let root: SbbStepperElement;

beforeEach(async () => {
root = await fixture(
html`
<sbb-stepper selected-index="0">
<sbb-step-label>Test step label 1</sbb-step-label>
<sbb-step>Test step content 1</sbb-step>
<sbb-step-label>Test step label 2</sbb-step-label>
<sbb-step>Test step content 2</sbb-step>
<sbb-step-label disabled>Test step label 3</sbb-step-label>
<sbb-step>Test step content 3</sbb-step>
<sbb-step-label>Test step label 4</sbb-step-label>
</sbb-stepper>
`,
{ modules: ['./stepper.js', '../step.js', '../step-label.js'] },
);
});

it('renders', () => {
assert.instanceOf(root, SbbStepperElement);
});
});
Loading
Loading