Skip to content

Commit df088e4

Browse files
authored
Merge 9adce6d into 9f6f003
2 parents 9f6f003 + 9adce6d commit df088e4

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

packages/components/src/components/icon-button/icon-button.stories.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
href: '',
1313
target: '_blank',
1414
shape: 'round',
15+
ariaLabel: 'Icon Button',
1516
},
1617

1718
argTypes: {
@@ -92,11 +93,18 @@ export default {
9293
}
9394
}
9495
},
96+
ariaLabel: {
97+
control: { type: 'text' },
98+
description: 'Set the aria label of the icon button. Enhances accessibility.',
99+
table: {
100+
category: 'ifx-icon-button props'
101+
}
102+
},
95103
},
96104
};
97105

98106
const DefaultTemplate = args =>
99-
`<ifx-icon-button shape="${args.shape}" variant="${args.variant}" icon="${args.icon}" href="${args.href}" target="${args.target}" size="${args.size}" disabled="${args.disabled}">
107+
`<ifx-icon-button shape="${args.shape}" variant="${args.variant}" icon="${args.icon}" href="${args.href}" target="${args.target}" size="${args.size}" disabled="${args.disabled}" aria-label="${args.ariaLabel}">
100108
</ifx-icon-button>`;
101109

102110
export const Default = DefaultTemplate.bind({});

packages/components/src/components/icon-button/icon-button.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component, Prop, h, Host, Method, Element, Listen } from '@stencil/core';
22
import classNames from 'classnames';
3-
43

54
@Component({
65
tag: 'ifx-icon-button',
@@ -16,10 +15,11 @@ export class IconButton {
1615
@Prop() href: string;
1716
@Prop() target: string = '_self';
1817
@Prop() shape: string = 'round';
18+
@Prop() ariaLabel: string | null;
1919
@Element() el;
2020

2121
private focusableElement: HTMLElement;
22-
22+
2323
@Listen('click', { capture: true })
2424
handleClick(event: Event) {
2525
if (this.disabled) {
@@ -40,14 +40,14 @@ export class IconButton {
4040

4141
render() {
4242
return (
43-
<Host>
43+
<Host
44+
aria-disabled={this.disabled}
45+
aria-label={this.ariaLabel}>
4446
{this.href ? (
4547
<a
46-
aria-disabled={this.disabled}
47-
aria-label='a clickable icon button'
4848
ref={(el) => (this.focusableElement = el)}
4949
class={this.getClassNames()}
50-
href={!this.disabled ? this.href : undefined}
50+
href={!this.disabled ? this.href : undefined}
5151
target={this.target}
5252
rel={this.target === '_blank' ? 'noopener noreferrer' : undefined}
5353
>
@@ -57,6 +57,7 @@ export class IconButton {
5757
<button
5858
class={this.getClassNames()}
5959
type="button"
60+
disabled={this.disabled}
6061
>
6162
<ifx-icon icon={this.icon}></ifx-icon>
6263
</button>

packages/components/src/components/icon-button/readme.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
## Properties
99

10-
| Property | Attribute | Description | Type | Default |
11-
| ---------- | ---------- | ----------- | ---------------------------------------- | ----------- |
12-
| `disabled` | `disabled` | | `boolean` | `undefined` |
13-
| `href` | `href` | | `string` | `undefined` |
14-
| `icon` | `icon` | | `string` | `undefined` |
15-
| `shape` | `shape` | | `string` | `'round'` |
16-
| `size` | `size` | | `string` | `undefined` |
17-
| `target` | `target` | | `string` | `'_self'` |
18-
| `variant` | `variant` | | `"primary" \| "secondary" \| "tertiary"` | `undefined` |
10+
| Property | Attribute | Description | Type | Default |
11+
| ----------- | ------------ | ----------- | ---------------------------------------- | ----------- |
12+
| `ariaLabel` | `aria-label` | | `string` | `undefined` |
13+
| `disabled` | `disabled` | | `boolean` | `undefined` |
14+
| `href` | `href` | | `string` | `undefined` |
15+
| `icon` | `icon` | | `string` | `undefined` |
16+
| `shape` | `shape` | | `string` | `'round'` |
17+
| `size` | `size` | | `string` | `undefined` |
18+
| `target` | `target` | | `string` | `'_self'` |
19+
| `variant` | `variant` | | `"primary" \| "secondary" \| "tertiary"` | `undefined` |
1920

2021

2122
## Methods

0 commit comments

Comments
 (0)