Skip to content

Commit

Permalink
docs: add section about focus outlines (#2634)
Browse files Browse the repository at this point in the history
Co-authored-by: Tommmaso Menga <[email protected]>
  • Loading branch information
jeripeierSBB and TomMenga authored May 7, 2024
1 parent 3572fa9 commit ec653f1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
22 changes: 22 additions & 0 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,28 @@ All our tokens and components use `rem` as size unit.
We strongly recommend using the `rem` unit to guarantee consistent scaling
when font size changes in browsers.

### Focus outline

Focus outlines should only be displayed when users are navigating by keyboard.
Lyne components use the CSS selector `:focus-visible`, to achieve that. Whenever you have custom interactive elements,
you should use the `:focus-visible` selector as well and include our SASS mixin `focus-outline`.

```scss
@use '../../core/styles' as sbb;

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

#### Dark background

If a container element has a dark background color, all containing interactive elements should get a white outline.
By setting `--sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);` all descendants elements using the
Lyne focus outline mixin (Lyne components included) receive the white outline because the variable gets inherited.
Note: If a Lyne component has a `negative` property, the correct focus outline color gets automatically applied
to all contained interactive elements.

### Stacking

As we can't use popover API yet, stacking of overlay context is done manually.
Expand Down
30 changes: 15 additions & 15 deletions src/storybook/styles/layout/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ Two items placed on grid using each 2 of 4 columns.

Using columns in the middle of the grid (e.g. alerts in home stories).

```sass
@use '@sbb-esta/lyne-components' as sbb;
.grid-reduced-width {
grid-column: 1/-1;
@include sbb.mq($from: large) {
grid-column: 2/-2;
}
@include sbb.mq($from: wide) {
grid-column: 3/-3;
}
@include sbb.mq($from: ultra) {
grid-column: 4/-4;
}
```scss
@use '@sbb-esta/lyne-components' as sbb;

.grid-reduced-width {
grid-column: 1/-1;

@include sbb.mq($from: large) {
grid-column: 2/-2;
}
@include sbb.mq($from: wide) {
grid-column: 3/-3;
}
@include sbb.mq($from: ultra) {
grid-column: 4/-4;
}
}
```

```html
Expand Down

0 comments on commit ec653f1

Please sign in to comment.