Skip to content

Commit

Permalink
fix(core/blind): improve keyboard accessibility (#461)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Maurer <[email protected]>
Co-authored-by: Daniel Leroux <[email protected]>
  • Loading branch information
3 people authored Mar 31, 2023
1 parent c509ec4 commit db091cc
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 13 deletions.
9 changes: 7 additions & 2 deletions packages/core/src/components/blind/blind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
overflow: hidden;

.blind-header {
all: unset;
@include ellipsis;

display: flex;
Expand All @@ -31,7 +32,7 @@
border: solid var(--theme-blind--border-thickness) transparent;
border-radius: var(--theme-blind--border-radius)
var(--theme-blind--border-radius) 0 0;
padding-right: $default-space;
padding-right: $small-space;
transition: border-radius $default-time;
cursor: pointer;

Expand All @@ -51,9 +52,12 @@
display: flex;
align-items: center;
flex-grow: 1;
height: 100%;

.blind-header-title-default {
@include ellipsis;
@include text-l-title;
margin-inline-end: $small-space;
flex-grow: 1;
}
}
Expand All @@ -79,7 +83,8 @@
}

@include focus-visible {
border-color: var(--theme-focus--border-color);
border-color: var(--theme-color-focus-bdr);
outline: none;
}

&.closed {
Expand Down
36 changes: 25 additions & 11 deletions packages/core/src/components/blind/blind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@stencil/core';
import anime from 'animejs';

let sequentialInstanceId = 0;
@Component({
tag: 'ix-blind',
styleUrl: 'blind.scss',
Expand Down Expand Up @@ -49,6 +50,7 @@ export class Blind {
@Element() hostElement!: HTMLIxBlindElement;

private chevronRef: HTMLElement;
private id = ++sequentialInstanceId;

constructor() {}

Expand Down Expand Up @@ -118,21 +120,28 @@ export class Blind {
render() {
return (
<Host>
<div
<button
class={{
'blind-header': true,
closed: this.collapsed,
}}
type="button"
aria-labelledby={`ix-blind-header-title-${this.id}`}
aria-controls={`ix-blind-content-section-${this.id}`}
aria-expanded={!this.collapsed}
onClick={(e) => this.onHeaderClick(e)}
>
<span
ref={(ref) => (this.chevronRef = ref)}
class={{
glyph: true,
'glyph-chevron-right-small': true,
}}
ref={(ref) => (this.chevronRef = ref)}
></span>
<div class="blind-header-title">
<div
class="blind-header-title"
id={`ix-blind-header-title-${this.id}`}
>
{this.label !== undefined ? (
<span class="blind-header-title-basic">
{this.icon !== undefined ? (
Expand All @@ -149,15 +158,20 @@ export class Blind {
<slot name="custom-header"></slot>
)}
</div>
</div>
<div
class={{
'blind-content': true,
hide: this.collapsed,
}}
</button>
<section
id={`ix-blind-content-section-${this.id}`}
aria-labelledby={`ix-blind-header-title-${this.id}`}
>
<slot></slot>
</div>
<div
class={{
'blind-content': true,
hide: this.collapsed,
}}
>
<slot></slot>
</div>
</section>
</Host>
);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db091cc

Please sign in to comment.