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 104 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
10 changes: 10 additions & 0 deletions src/elements/core/styles/a11y.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
.sbb-screen-reader-only {
@include a11y.screen-reader-only;
}

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

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

--sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);
}
3 changes: 3 additions & 0 deletions src/elements/stepper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './stepper/step.js';
export * from './stepper/step-label.js';
export * from './stepper/stepper.js';
1 change: 1 addition & 0 deletions src/elements/stepper/step-label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './step-label/step-label.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["sbb-step-label renders Dom"] =
`<sbb-step-label
data-action=""
data-button=""
dir="ltr"
id="sbb-step-label-0"
role="tab"
slot="step-label"
tabindex="-1"
>
Label
</sbb-step-label>
`;
/* end snapshot sbb-step-label renders Dom */

snapshots["sbb-step-label renders ShadowDom"] =
`<div class="sbb-step-label">
<span class="sbb-step-label__prefix">
<slot name="icon">
</slot>
</span>
<span class="sbb-step-label__text">
<slot>
</slot>
</span>
</div>
`;
/* end snapshot sbb-step-label renders ShadowDom */

snapshots["sbb-step-label renders with icon Dom"] =
`<sbb-step-label
data-action=""
data-button=""
dir="ltr"
icon-name="tick-small"
id="sbb-step-label-2"
role="tab"
slot="step-label"
tabindex="-1"
>
Label
</sbb-step-label>
`;
/* end snapshot sbb-step-label renders with icon Dom */

snapshots["sbb-step-label renders with icon ShadowDom"] =
`<div class="sbb-step-label">
<span class="sbb-step-label__prefix">
<slot name="icon">
<sbb-icon
aria-hidden="true"
data-namespace="default"
name="tick-small"
role="img"
>
</sbb-icon>
</slot>
</span>
<span class="sbb-step-label__text">
<slot>
</slot>
</span>
</div>
`;
/* end snapshot sbb-step-label renders with icon ShadowDom */

snapshots["sbb-step-label renders disabled Dom"] =
`<sbb-step-label
data-action=""
data-button=""
data-disabled=""
dir="ltr"
disabled=""
id="sbb-step-label-4"
role="tab"
slot="step-label"
tabindex="-1"
>
Label
</sbb-step-label>
`;
/* end snapshot sbb-step-label renders disabled Dom */

snapshots["sbb-step-label renders disabled ShadowDom"] =
`<div class="sbb-step-label">
<span class="sbb-step-label__prefix">
<slot name="icon">
</slot>
</span>
<span class="sbb-step-label__text">
<slot>
</slot>
</span>
</div>
`;
/* end snapshot sbb-step-label renders disabled ShadowDom */

snapshots["sbb-step-label A11y tree Chrome"] =
`<p>
{
"role": "WebArea",
"name": "",
"children": [
{
"role": "tab",
"name": "Label"
}
]
}
</p>
`;
/* end snapshot sbb-step-label A11y tree Chrome */

snapshots["sbb-step-label A11y tree Firefox"] =
`<p>
{
"role": "document",
"name": "",
"children": [
{
"role": "tab",
"name": "Label"
}
]
}
</p>
`;
/* end snapshot sbb-step-label A11y tree Firefox */

54 changes: 54 additions & 0 deletions src/elements/stepper/step-label/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Use the `sbb-step-label` with the `sbb-stepper` to display a step label.

```html
<sbb-step-label>Step label</sbb-step-label>
```

## Slots

It has an implicit slot named `step-label`.

## States

The component can be displayed in `disabled` state using the self-named property.

```html
<sbb-step-label disabled>Step label</sbb-step-label>
```

## Style

If it is used in an `sbb-stepper` and no `icon-name` is specified, it displays a counter in the label prefix to keep track of the step number.

```html
<!-- Displays a tick icon in the prefix circle -->
<sbb-step-label icon-name="tick-small">Step label</sbb-step-label>

<!-- Displays a number in the prefix circle -->
<sbb-step-label>Step label</sbb-step-label>
```

## Accessibility

The accessibility properties `aria-controls`, `aria-setsize`, `aria-posinset` are set automatically.

<!-- Auto Generated Below -->

## Properties

| Name | Attribute | Privacy | Type | Default | Description |
| ---------- | ----------- | ------- | ------------------------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
| `form` | `form` | public | `string \| undefined` | | The <form> element to associate the button with. |
| `iconName` | `icon-name` | public | `string \| undefined` | | The icon name we want to use, choose from the small icon variants from the ui-icons category from here https://icons.app.sbb.ch. |
| `name` | `name` | public | `string` | | The name of the button element. |
| `step` | - | public | `SbbStepElement \| null` | `null` | The step controlled by the label. |
| `type` | `type` | public | `SbbButtonType` | `'button'` | The type attribute to use for the button. |
| `value` | `value` | public | `string` | | The value of the button element. |

## Slots

| Name | Description |
| ------ | ------------------------------------------------ |
| | Use the unnamed slot to provide a label. |
| `icon` | Use this to display an icon in the label bubble. |
153 changes: 153 additions & 0 deletions src/elements/stepper/step-label/step-label.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
@use '../../core/styles' as sbb;

// Box-sizing rules contained in typography are not traversing Shadow DOM boundaries. We need to include box-sizing mixin in every component.
@include sbb.box-sizing;

:host {
--sbb-step-label-color: var(--sbb-color-iron);
--sbb-step-label-animation-duration: var(
--sbb-disable-animation-zero-time,
var(--sbb-animation-duration-2x)
);
--sbb-step-label-prefix-size: var(--sbb-size-element-xxs);
--sbb-step-label-prefix-border-style: solid;
--sbb-step-label-prefix-border-color: var(--sbb-color-cloud);
--sbb-step-label-prefix-background-color: var(--sbb-color-white);

position: relative;
min-width: 0;
max-width: fit-content;

&::before {
@include sbb.text-xxs--regular;
@include sbb.absolute-center-x-y;

cursor: var(--sbb-step-label-cursor);
color: var(--sbb-step-label-color);

// The `--sbb-font-size-text-l` is beign used here to align the bubble's inner text to
// the label text which includes the `sbb.text-l--bold` mixin.
inset-block-start: calc(
var(--sbb-font-size-text-l) * (var(--sbb-typo-line-height-body-text) / 2) +
(var(--sbb-border-width-1x) / 2)
);
inset-inline-start: calc(var(--sbb-step-label-prefix-size) / 2);
line-height: 1;
z-index: 1;
transform: translate(
-50%,
calc(-50% + var(--sbb-step-label-translate-y-content-hover, #{sbb.px-to-rem-build(0)}))
dauriamarco marked this conversation as resolved.
Show resolved Hide resolved
);
transition: transform var(--sbb-step-label-animation-duration) var(--sbb-animation-easing);
}

@include sbb.if-forced-colors {
--sbb-step-label-color: ButtonText;
--sbb-step-label-prefix-border-color: ButtonText;
}
}

:host([data-selected]) {
@include sbb.text-xxs--bold;

--sbb-step-label-color: var(--sbb-color-charcoal);

@include sbb.if-forced-colors {
--sbb-step-label-color: Highlight !important;
}
}

:host([disabled]) {
--sbb-step-label-color: var(--sbb-color-granite);
--sbb-step-label-prefix-border-style: dashed;

@include sbb.if-forced-colors {
--sbb-step-label-color: GrayText !important;
}
}

:host(:hover:not([disabled])) {
@include sbb.hover-mq($hover: true) {
--sbb-step-label-cursor: pointer;
--sbb-step-label-prefix-background-color: var(--sbb-color-milk);
--sbb-step-label-translate-y-content-hover: #{sbb.px-to-rem-build(-1)};
--sbb-step-label-prefix-size-grow-hover: calc(var(--sbb-border-width-2x) * -1);
}
}

// Hide focus outline when focus origin is mouse or touch. This is being used as a workaround in various components.
:host(:focus-visible:not([data-focus-origin='mouse'], [data-focus-origin='touch'])) {
@include sbb.focus-outline;

border-radius: var(--sbb-border-radius-1x);
}

:host([data-orientation='vertical']) {
transition: margin var(--sbb-stepper-animation-duration) var(--sbb-animation-easing);
}

:host([data-orientation='vertical']:not(:first-of-type)) {
margin-block-start: var(--sbb-spacing-fixed-6x);
}

:host([data-selected][data-orientation='vertical']) {
margin-block-end: var(--sbb-spacing-fixed-8x);
}

.sbb-step-label {
@include sbb.text-l--bold;

cursor: var(--sbb-step-label-cursor);
position: relative;
display: flex;
gap: var(--sbb-spacing-fixed-4x);
color: var(--sbb-step-label-color);
}

.sbb-step-label__prefix {
position: relative;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: var(--sbb-step-label-prefix-size);
height: var(--sbb-step-label-prefix-size);
inset-block-start: calc(
1em * (var(--sbb-typo-line-height-body-text) / 2) + (var(--sbb-border-width-1x) / 2) -
(var(--sbb-step-label-prefix-size) / 2)
);

&::before {
content: '';
position: absolute;
inset: calc(var(--sbb-step-label-prefix-size-grow-hover, #{sbb.px-to-rem-build(0)}));
dauriamarco marked this conversation as resolved.
Show resolved Hide resolved
border-radius: var(--sbb-border-radius-infinity);
border: var(--sbb-border-width-1x) var(--sbb-step-label-prefix-border-style)
var(--sbb-step-label-prefix-border-color);
background-color: var(--sbb-step-label-prefix-background-color);
transition: {
duration: var(--sbb-step-label-animation-duration);
timing-function: var(--sbb-animation-easing);
property: background-color, inset;
}
}
}

.sbb-step-label__text {
:host([data-orientation='horizontal']) & {
@include sbb.ellipsis;
}
}

::slotted(sbb-icon),
sbb-icon {
z-index: 1;
background-color: var(--sbb-step-label-prefix-background-color);
border-radius: var(--sbb-border-radius-infinity);
transform: translateY(var(--sbb-step-label-translate-y-content-hover, #{sbb.px-to-rem-build(0)}));
dauriamarco marked this conversation as resolved.
Show resolved Hide resolved
transition: {
duration: var(--sbb-step-label-animation-duration);
timing-function: var(--sbb-animation-easing);
property: background-color, transform;
}
}
Loading
Loading