1
- import { Component , type FunctionalComponent , Host , Prop , h } from '@stencil/core' ;
1
+ import { Component , type FunctionalComponent , Host , Listen , Prop , h } from '@stencil/core' ;
2
2
import { type OdsIconName } from '../../../../icon/src/constants/icon-name' ;
3
3
import { ODS_LINK_COLOR , type OdsLinkColor } from '../../constant/link-color' ;
4
4
@@ -18,28 +18,35 @@ export class OdsLink {
18
18
@Prop ( { reflect : true } ) public rel ?: HTMLAnchorElement [ 'rel' ] ;
19
19
@Prop ( { reflect : true } ) public target ?: HTMLAnchorElement [ 'target' ] ;
20
20
21
+ @Listen ( 'click' )
22
+ onClick ( event : MouseEvent ) : void {
23
+ if ( this . disabled ) {
24
+ event . preventDefault ( ) ;
25
+ event . stopPropagation ( ) ;
26
+ }
27
+ }
28
+
21
29
render ( ) : FunctionalComponent {
22
30
return (
23
- < Host class = 'ods-link' >
24
- < a
25
- class = { {
26
- 'ods-link__link' : true ,
27
- 'ods-link__link--disabled' : this . disabled ?? false ,
28
- [ `ods-link__link--${ this . color } ` ] : true ,
29
- } }
30
- download = { this . download }
31
- href = { this . href }
32
- part = "link"
33
- referrerPolicy = { this . referrerpolicy }
34
- rel = { this . rel }
35
- tabindex = { this . disabled ? - 1 : 0 }
36
- target = { this . target } >
31
+ < Host class = "ods-link" >
32
+ < a class = { {
33
+ 'ods-link__link' : true ,
34
+ 'ods-link__link--disabled' : this . disabled ?? false ,
35
+ [ `ods-link__link--${ this . color } ` ] : true ,
36
+ } }
37
+ download = { this . download }
38
+ href = { this . href }
39
+ part = "link"
40
+ referrerPolicy = { this . referrerpolicy }
41
+ rel = { this . rel }
42
+ tabindex = { this . disabled ? - 1 : 0 }
43
+ target = { this . target } >
37
44
< span class = "ods-link__link__text" >
38
45
{ this . label }
39
46
</ span >
40
47
41
48
{
42
- ! ! this . icon && < ods-icon name = { this . icon } > </ ods-icon >
49
+ ! ! this . icon && < ods-icon part = "icon" name = { this . icon } class = "ods-link__link__icon" > </ ods-icon >
43
50
}
44
51
</ a >
45
52
</ Host >
0 commit comments