Skip to content

Commit

Permalink
fix(core): improve component a11y (#1497)
Browse files Browse the repository at this point in the history
Co-authored-by: matthiashader <[email protected]>
Co-authored-by: matthias <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent a100af7 commit eb97f91
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 226 deletions.
7 changes: 7 additions & 0 deletions .changeset/eight-windows-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siemens/ix-angular": minor
"@siemens/ix": minor
"@siemens/ix-vue": minor
---

feat(core): improve component a11y
4 changes: 2 additions & 2 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ export declare interface IxCardTitle extends Components.IxCardTitle {}


@ProxyCmp({
inputs: ['categories', 'disabled', 'filterState', 'hideIcon', 'i18nPlainText', 'icon', 'labelCategories', 'nonSelectableCategories', 'placeholder', 'readonly', 'repeatCategories', 'staticOperator', 'suggestions']
inputs: ['ariaLabel', 'categories', 'disabled', 'filterState', 'hideIcon', 'i18nPlainText', 'icon', 'labelCategories', 'nonSelectableCategories', 'placeholder', 'readonly', 'repeatCategories', 'staticOperator', 'suggestions']
})
@Component({
selector: 'ix-category-filter',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['categories', 'disabled', 'filterState', 'hideIcon', 'i18nPlainText', 'icon', 'labelCategories', 'nonSelectableCategories', 'placeholder', 'readonly', 'repeatCategories', 'staticOperator', 'suggestions'],
inputs: ['ariaLabel', 'categories', 'disabled', 'filterState', 'hideIcon', 'i18nPlainText', 'icon', 'labelCategories', 'nonSelectableCategories', 'placeholder', 'readonly', 'repeatCategories', 'staticOperator', 'suggestions'],
})
export class IxCategoryFilter {
protected el: HTMLElement;
Expand Down
49 changes: 40 additions & 9 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand All @@ -604,7 +604,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand All @@ -625,7 +625,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand All @@ -651,7 +651,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
}
],
Expand Down Expand Up @@ -2154,6 +2154,33 @@
]
},
"props": [
{
"name": "ariaLabel",
"type": "string",
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"mutable": false,
"attr": "aria-label",
"reflectToAttr": false,
"docs": "Aria label for the filter input field",
"docsTags": [
{
"name": "since",
"text": "2.6.0"
}
],
"default": "'Filter'",
"values": [
{
"type": "string"
}
],
"optional": false,
"required": false
},
{
"name": "categories",
"type": "{ [id: string]: { label: string; options: string[]; }; }",
Expand Down Expand Up @@ -6302,6 +6329,7 @@
"reflectToAttr": false,
"docs": "Display a chevron icon in list items. Defaults to 'false'",
"docsTags": [],
"default": "false",
"values": [
{
"type": "boolean"
Expand Down Expand Up @@ -6399,6 +6427,7 @@
"reflectToAttr": false,
"docs": "Show chevron on right side of the event list item",
"docsTags": [],
"default": "false",
"values": [
{
"type": "boolean"
Expand Down Expand Up @@ -6435,7 +6464,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand All @@ -6451,6 +6480,7 @@
"reflectToAttr": false,
"docs": "Disable event list item",
"docsTags": [],
"default": "false",
"values": [
{
"type": "boolean"
Expand Down Expand Up @@ -6482,7 +6512,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand All @@ -6498,6 +6528,7 @@
"reflectToAttr": false,
"docs": "Show event list item as selected",
"docsTags": [],
"default": "false",
"values": [
{
"type": "boolean"
Expand Down Expand Up @@ -9281,7 +9312,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand Down Expand Up @@ -12186,7 +12217,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand Down Expand Up @@ -12229,7 +12260,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand Down
28 changes: 19 additions & 9 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,20 @@ export namespace Components {
* Optional description text that will be displayed underneath the username. Note: Only working if avatar is part of the ix-application-header
* @since 2.1.0
*/
"extra": string;
"extra"?: string;
/**
* Display an avatar image
*/
"image": string;
"image"?: string;
/**
* Display the initials of the user. Will be overwritten by image
*/
"initials": string;
"initials"?: string;
/**
* If set an info card displaying the username will be placed inside the dropdown. Note: Only working if avatar is part of the ix-application-header
* @since 2.1.0
*/
"username": string;
"username"?: string;
}
interface IxBasicNavigation {
/**
Expand Down Expand Up @@ -366,6 +366,11 @@ export namespace Components {
interface IxCardTitle {
}
interface IxCategoryFilter {
/**
* Aria label for the filter input field
* @since 2.6.0
*/
"ariaLabel": string;
/**
* Configuration object hash used to populate the dropdown menu for type-ahead and quick selection functionality. Each ID maps to an object with a label and an array of options to select from.
*/
Expand Down Expand Up @@ -987,7 +992,7 @@ export namespace Components {
* @link https://ix.siemens.io/docs/theming/colors/
* @deprecated since 2.1.0 use `item-color`
*/
"color": string;
"color"?: string;
/**
* Disable event list item
*/
Expand All @@ -996,7 +1001,7 @@ export namespace Components {
* Color of the status indicator. You can find a list of all available colors in our documentation. Example values are `--theme-color-alarm` or `color-alarm`
* @link https://ix.siemens.io/docs/theming/colors/
*/
"itemColor": string;
"itemColor"?: string;
/**
* Show event list item as selected
*/
Expand Down Expand Up @@ -1348,7 +1353,7 @@ export namespace Components {
/**
* Should only be set if you use ix-menu standalone
*/
"applicationName": string;
"applicationName"?: string;
/**
* Internal
*/
Expand Down Expand Up @@ -1740,15 +1745,15 @@ export namespace Components {
/**
* Title of the side panel
*/
"heading": string;
"heading"?: string;
/**
* Define if the pane should have a collapsed state
*/
"hideOnCollapse": boolean;
/**
* Name of the icon
*/
"icon": string;
"icon"?: string;
"ignoreLayoutSettings": boolean;
"isMobile": boolean;
/**
Expand Down Expand Up @@ -4442,6 +4447,11 @@ declare namespace LocalJSX {
interface IxCardTitle {
}
interface IxCategoryFilter {
/**
* Aria label for the filter input field
* @since 2.6.0
*/
"ariaLabel"?: string;
/**
* Configuration object hash used to populate the dropdown menu for type-ahead and quick selection functionality. Each ID maps to an object with a label and an array of options to select from.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/avatar/avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

@include btn-base-variant('invisible-primary', false);

li {
.avatar {
transform: scale(0.8);
}
}
39 changes: 22 additions & 17 deletions packages/core/src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ function DefaultAvatar(props: { initials?: string }) {
);
}

function AvatarImage(props: { image: string; initials: string }) {
function AvatarImage(props: { image?: string; initials?: string }) {
return (
<li class="avatar">
<div class="avatar">
{props.image ? (
<img src={props.image} class="avatar-image"></img>
) : (
<DefaultAvatar initials={props.initials} />
)}
</li>
</div>
);
}

function UserInfo(props: {
image: string;
initials: string;
image?: string;
initials?: string;
userName: string;
extra: string;
extra?: string;
}) {
return (
<Fragment>
Expand Down Expand Up @@ -97,41 +97,41 @@ function UserInfo(props: {
shadow: true,
})
export class Avatar {
@Element() hostElement: HTMLIxAvatarElement;
@Element() hostElement!: HTMLIxAvatarElement;

/**
* Display an avatar image
*
*/
@Prop() image: string;
@Prop() image?: string;

/**
* Display the initials of the user. Will be overwritten by image
*
*/
@Prop() initials: string;
@Prop() initials?: string;

/**
* If set an info card displaying the username will be placed inside the dropdown.
* Note: Only working if avatar is part of the ix-application-header
*
* @since 2.1.0
*/
@Prop() username: string;
@Prop() username?: string;

/**
* Optional description text that will be displayed underneath the username.
* Note: Only working if avatar is part of the ix-application-header
*
* @since 2.1.0
*/
@Prop() extra: string;
@Prop() extra?: string;

@State() isClosestApplicationHeader = false;
@State() hasSlottedElements = false;

private slotElement: HTMLSlotElement;
private dropdownElement: HTMLIxDropdownElement;
private slotElement?: HTMLSlotElement;
private dropdownElement?: HTMLIxDropdownElement;

componentWillLoad() {
const closest = closestElement('ix-application-header', this.hostElement);
Expand All @@ -143,10 +143,15 @@ export class Avatar {
}

private resolveAvatarTrigger() {
return new Promise<HTMLElement>((resolve) => {
readTask(() =>
resolve(this.hostElement.shadowRoot.querySelector('button'))
);
return new Promise<HTMLElement>((resolve, reject) => {
readTask(() => {
const button = this.hostElement.shadowRoot!.querySelector('button');
if (button) {
resolve(button);
} else {
reject(new Error('ix-avatar - trigger element not found'));
}
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@
.list-unstyled {
display: flex;
flex-wrap: wrap;
list-style: none;
padding: 0;
margin: 0;
height: 100%;
overflow-y: auto;
}

Expand Down Expand Up @@ -126,7 +124,7 @@
height: 100%;
}

ul > li,
.list-unstyled > span:not(.category-preview),
input {
padding-inline-start: 0;
padding-top: 2px;
Expand Down
Loading

0 comments on commit eb97f91

Please sign in to comment.