Skip to content

Commit e6413b5

Browse files
committed
Fix types of icon component passed to au-icon
1 parent 0881da2 commit e6413b5

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

addon/components/au-accordion.gts

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ import { tracked } from '@glimmer/tracking';
55
import { modifier } from 'ember-modifier';
66
import AuButton from './au-button';
77
import AuContent from './au-content';
8-
import AuIcon from './au-icon';
8+
import AuIcon, { type AuIconSignature } from './au-icon';
99
import AuLoader from './au-loader';
1010
import AuToolbar from './au-toolbar';
1111

1212
const autofocus = modifier(function autofocus(element: HTMLElement) {
1313
element.focus();
1414
});
1515

16+
const iconTestName = (icon: AuIconSignature['Args']['icon']): string =>
17+
typeof icon === 'string' ? icon : icon.toString();
18+
1619
export interface AuAccordionSignature {
1720
Args: {
1821
buttonLabel?: string;
19-
iconClosed?: string;
20-
iconOpen?: string;
22+
iconClosed?: AuIconSignature['Args']['icon'];
23+
iconOpen?: AuIconSignature['Args']['icon'];
2124
isOpenInitially?: boolean;
2225
loading?: boolean;
2326
reverse?: boolean;
@@ -107,15 +110,15 @@ export default class AuAccordion extends Component<AuAccordionSignature> {
107110
@alignment="left"
108111
@size="large"
109112
@ariaHidden={{true}}
110-
data-test-accordion-icon-open={{this.iconOpen}}
113+
data-test-accordion-icon-open={{iconTestName this.iconOpen}}
111114
/>
112115
{{else}}
113116
<AuIcon
114117
@icon={{this.iconClosed}}
115118
@alignment="left"
116119
@size="large"
117120
@ariaHidden={{true}}
118-
data-test-accordion-icon-closed={{this.iconClosed}}
121+
data-test-accordion-icon-closed={{iconTestName this.iconClosed}}
119122
/>
120123
{{/if}}
121124
</Group>

addon/components/au-icon.gts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export interface AuIconSignature {
77
alignment?: 'left' | 'right';
88
// TODO: We should deprecate the non-boolean versions since there is no reason to support them
99
ariaHidden?: boolean | 'true' | 'false';
10-
icon: string | ComponentLike<Record<string, never>>;
10+
icon: string | ComponentLike<{ Element: Element }>;
1111
size?: 'large';
1212
};
13-
Element: SVGSVGElement;
13+
Element: Element;
1414
}
1515

1616
export default class AuIcon extends Component<AuIconSignature> {
@@ -47,10 +47,10 @@ export default class AuIcon extends Component<AuIconSignature> {
4747
<template>
4848
{{#if this.iconComponent}}
4949
{{#let this.iconComponent as |Icon|}}
50-
{{! @glint-expect-error: glint doesn't like us setting attributes on the passed component }}
5150
<Icon
5251
class="au-c-icon {{this.alignment}} {{this.size}}"
5352
aria-hidden={{this.ariaHidden}}
53+
...attributes
5454
/>
5555
{{/let}}
5656
{{else}}

addon/components/au-link-external.gts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Component from '@glimmer/component';
2-
import AuIcon from './au-icon';
2+
import AuIcon, { type AuIconSignature } from './au-icon';
33

44
const SKIN_CLASSES = {
55
primary: 'au-c-link',
@@ -12,7 +12,7 @@ const SKIN_CLASSES = {
1212
export interface AuLinkExternalSignature {
1313
Args: {
1414
hideText?: boolean;
15-
icon?: string;
15+
icon?: AuIconSignature['Args']['icon'];
1616
iconAlignment?: 'left' | 'right';
1717
skin?:
1818
| 'primary'

0 commit comments

Comments
 (0)