Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Component, ComponentInterface, Prop, h } from '@stencil/core';
@Component({
tag: 'hy-standalone-link',
styleUrl: 'standalone-link.scss',
shadow: true,
})
export class StandaloneLink implements ComponentInterface {
@Prop() linkContent: string = '';
@Prop() url?: string;
@Prop() ariaLabel?: string;
@Prop() isExternal: boolean = false;
@Prop() isEnabled: boolean = true;
render() {
const containerClassAttributes = ["hy-standalone-link-container"].join(" ");
const classAttributes = ["hy-standalone-link",
this.isEnabled ? "enabled" : "disabled"
];
const textClassAttributes = ["hy-standalone-link__text"].join(" ");
const iconClassAttributes = [
"hy-standalone-link__link-icon",
this.isExternal ? "hy-standalone-link__link-icon--external" : null
].join(" ");
const target = this.isExternal ? "_blank" : "_self";
return (
<span class={containerClassAttributes}>
<a
aria-label={this.ariaLabel}
class={classAttributes.join(" ")}
href={this.url}
target={target}
>
<span class={textClassAttributes}>
{this.linkContent}
</span>
<span class={iconClassAttributes}>
<hy-icon icon={'hy-icon-arrow-right'} size={16} />
</span>
</a>
</span>
);
}
}