Skip to content

Commit

Permalink
Merge pull request #1503 from Infineon/1264-accessibility-enhancement…
Browse files Browse the repository at this point in the history
…-of-accordion

Enhancement: Accessibility enhancement of accordion
  • Loading branch information
tishoyanchev authored Oct 22, 2024
2 parents 6c57eec + e969a3f commit 31d1b2c
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 136 deletions.
197 changes: 95 additions & 102 deletions examples/wrapper-components/react-vite-js/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/wrapper-components/react-vite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-react": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"@infineon/infineon-design-system-react": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"path": "^0.12.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper-components/vue-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-vue": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"@infineon/infineon-design-system-vue": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"vite": "^5.0.12",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"command": {
"publish": {
"verifyAccess": false
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/components-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "components-angular",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -26,7 +26,7 @@
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@infineon/infineon-design-system-angular": "^25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"@infineon/infineon-design-system-angular": "^25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typescript": "~5.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-angular",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"description": "Infineon design system Stencil web components for Angular",
"author": "Verena Lechner",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"@angular/common": "^18.0.0",
"@angular/core": "^18.0.0",
"@infineon/design-system-tokens": "3.3.3",
"@infineon/infineon-design-system-stencil": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0"
"@infineon/infineon-design-system-stencil": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0"
},
"dependencies": {
"tslib": "^2.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-react",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"description": "Infineon design system Stencil web components for React",
"main": "./dist/index.js",
"types": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.3",
"@infineon/infineon-design-system-stencil": "^25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"@infineon/infineon-design-system-stencil": "^25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"@stencil/react-output-target": "^0.7.1"
},
"auto": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-vue",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"description": "Infineon design system Stencil web components for Vue",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.3",
"@infineon/infineon-design-system-stencil": "^25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0"
"@infineon/infineon-design-system-stencil": "^25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0"
},
"auto": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-stencil",
"version": "25.10.1--canary.1544.b473cfd14ac9689b66c713ec72dcc87d8e764f29.0",
"version": "25.12.0--canary.1503.ad49b651a076acc83c8b6857c553d2c0bb92cb49.0",
"private": false,
"description": "Infineon design system Stencil web components",
"homepage": "https://infineon.github.io/infineon-design-system-stencil",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ export default {

args: {
autoCollapse: false,
AriaLevel: 3,
},

argTypes: {
amountOfItems: { control: 'number' },
AriaLevel: {
control: 'number',
min: 1,
max: 6,
description: 'The aria-level attribute for the accordion item header.'
},
},
};

Expand All @@ -19,6 +26,7 @@ const Template = args => {
const initialItem = document.createElement('ifx-accordion-item');
initialItem.setAttribute('caption', `Label`);
initialItem.setAttribute('open', `true`);
initialItem.setAttribute('aria-level', args.AriaLevel);

initialItem.innerHTML = `
Content for Initial Item. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent volutpat, ligula eu aliquam bibendum, orci nisl cursus ipsum, nec egestas odio sapien eget neque.
Expand All @@ -35,9 +43,12 @@ const Template = args => {
const item = document.createElement('ifx-accordion-item');
item.setAttribute('caption', `Label`);
item.setAttribute('open', `false`);
item.setAttribute('aria-level', args.AriaLevel);

item.innerHTML = `
Content for Item #${i + 1}. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent volutpat, ligula eu aliquam bibendum, orci nisl cursus ipsum, nec egestas odio sapien eget neque.
Content for Item #${
i + 1
}. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent volutpat, ligula eu aliquam bibendum, orci nisl cursus ipsum, nec egestas odio sapien eget neque.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent volutpat, ligula eu aliquam bibendum, orci nisl cursus ipsum, nec egestas odio sapien eget neque.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent volutpat, ligula eu aliquam bibendum, orci nisl cursus ipsum, nec egestas odio sapien eget neque.
`;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component, h, Listen, Element, Prop } from '@stencil/core';
@Component({
tag: 'ifx-accordion',
styleUrl: 'accordion.scss',
shadow: true,
shadow: { delegatesFocus: true },
})
export class Accordion {
@Element() el: HTMLElement;
Expand Down
20 changes: 20 additions & 0 deletions packages/components/src/components/accordion/accordionItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@

}

.accordion-title:focus {
outline: none;
}

// workaround to add corner radius to outline
.accordion-title:focus::after {
content: '';
display: block;
position: absolute;
top: -4px;
bottom: -4px;
left: -4px;
right: -4px;
border-radius: 5px;
border: 2px solid tokens.$ifxColorOcean500;
box-sizing: border-box;
}

.accordion-title:hover {
border: 1px solid tokens.$ifxColorEngineering200;
color: tokens.$ifxColorOcean600;
Expand All @@ -19,12 +37,14 @@
.accordion-title {
display: flex;
align-items: center;
position: relative;
padding: tokens.$ifxSpace150 tokens.$ifxSpace200;
gap: tokens.$ifxSpace150;
color: tokens.$ifxColorOcean500;
background-color: tokens.$ifxColorBaseWhite;
border: 1px solid tokens.$ifxColorEngineering200;
cursor: pointer;
margin: 4px;
}

.accordion-caption {
Expand Down
29 changes: 22 additions & 7 deletions packages/components/src/components/accordion/accordionItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//ifxAccordionItem
import { Component, Prop, h, State, Event, EventEmitter, Watch } from '@stencil/core';
import { Component, Prop, h, State, Event, EventEmitter, Watch, Listen } from '@stencil/core';

@Component({
tag: 'ifx-accordion-item',
Expand All @@ -11,6 +11,7 @@ export class IfxAccordionItem {
@Prop({
mutable: true,
}) open: boolean = false;
@Prop() AriaLevel = 3;
@State() internalOpen: boolean = false;
@Event() ifxItemOpen: EventEmitter;
@Event() ifxItemClose: EventEmitter;
Expand Down Expand Up @@ -79,16 +80,30 @@ export class IfxAccordionItem {
}
}



@Listen('keydown')
handleKeydown(ev: KeyboardEvent) {
switch (ev.key) {
case 'Enter': // fallthrough
case ' ': // space
ev.preventDefault();
this.toggleOpen();
break;
}
}


render() {
return (
<div aria-label={this.caption} class={`accordion-item ${this.internalOpen ? 'open' : ''}`}>
<div class="accordion-title" onClick={() => this.toggleOpen()}>
<span class="accordion-icon">
<ifx-icon icon="chevron-down-12" />
<div class={`accordion-item ${this.internalOpen ? 'open' : ''}`}>
<div role="button" aria-expanded={this.internalOpen} aria-controls="accordion-content" class="accordion-title" onClick={() => this.toggleOpen()} tabindex='0'>
<span aria-hidden="true" role="heading" aria-level={String(this.AriaLevel) as string} class="accordion-icon">
<ifx-icon icon="chevron-down-12"/>
</span>
<span class="accordion-caption">{this.caption}</span>
<span id="accordion-caption" class="accordion-caption">{this.caption}</span>
</div>
<div class="accordion-content" ref={(el) => (this.contentEl = el as HTMLElement)}>
<div id="accordion-content" class="accordion-content" ref={(el) => (this.contentEl = el as HTMLElement)} role="region" aria-labelledby="accordion-caption">
<div class="inner-content">
<slot onSlotchange={(e) => this.handleSlotChange(e)} />
</div>
Expand Down
9 changes: 5 additions & 4 deletions packages/components/src/components/accordion/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

## Properties

| Property | Attribute | Description | Type | Default |
| --------- | --------- | ----------- | --------- | ----------- |
| `caption` | `caption` | | `string` | `undefined` |
| `open` | `open` | | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ----------- | ------------ | ----------- | --------- | ----------- |
| `AriaLevel` | `aria-level` | | `number` | `3` |
| `caption` | `caption` | | `string` | `undefined` |
| `open` | `open` | | `boolean` | `false` |


## Events
Expand Down

0 comments on commit 31d1b2c

Please sign in to comment.