File tree 1 file changed +26
-11
lines changed
1 file changed +26
-11
lines changed Original file line number Diff line number Diff line change 1
1
import { getOwner } from ' @ember/owner' ;
2
2
import Component from ' @glimmer/component' ;
3
+ import { type ComponentLike } from ' @glint/template' ;
3
4
4
5
export interface AuIconSignature {
5
6
Args: {
6
7
alignment? : ' left' | ' right' ;
7
8
// TODO: We should deprecate the non-boolean versions since there is no reason to support them
8
9
ariaHidden? : boolean | ' true' | ' false' ;
9
- icon: string ;
10
+ icon: string | ComponentLike < Record < string , never >> ;
10
11
size? : ' large' ;
11
12
};
12
13
Element: SVGSVGElement ;
@@ -39,16 +40,30 @@ export default class AuIcon extends Component<AuIconSignature> {
39
40
}
40
41
}
41
42
43
+ get iconComponent() {
44
+ return typeof this .args .icon !== ' string' && this .args .icon ;
45
+ }
46
+
42
47
<template >
43
- <svg
44
- role =" img"
45
- class =" au-c-icon au-c-icon--{{@ icon }} {{this .alignment }} {{this .size }} "
46
- aria-hidden ={{this .ariaHidden }}
47
- ...attributes
48
- >
49
- <use
50
- xlink:href =" {{this .iconPrefix }} @appuniversum/ember-appuniversum/appuniversum-symbolset.svg#{{@ icon }} "
51
- ></use >
52
- </svg >
48
+ {{#if this . iconComponent }}
49
+ {{#let this . iconComponent as | Icon | }}
50
+ {{! @glint-expect-error: glint doesn't like us setting attributes on the passed component }}
51
+ <Icon
52
+ class =" au-c-icon {{this .alignment }} {{this .size }} "
53
+ aria-hidden ={{this .ariaHidden }}
54
+ />
55
+ {{/let }}
56
+ {{else }}
57
+ <svg
58
+ role =" img"
59
+ class =" au-c-icon au-c-icon--{{@ icon }} {{this .alignment }} {{this .size }} "
60
+ aria-hidden ={{this .ariaHidden }}
61
+ ...attributes
62
+ >
63
+ <use
64
+ xlink:href =" {{this .iconPrefix }} @appuniversum/ember-appuniversum/appuniversum-symbolset.svg#{{@ icon }} "
65
+ ></use >
66
+ </svg >
67
+ {{/if }}
53
68
</template >
54
69
}
You can’t perform that action at this time.
0 commit comments