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
48
49
50
51
52
53
54
55
import { Component, ComponentInterface, Prop, h } from '@stencil/core';
@Component({
tag: 'hy-link-box',
styleUrl: 'link-box.scss',
shadow: true,
})
export class LinkBox implements ComponentInterface {
@Prop() imageUrl: string = null;
@Prop() imageAlt: string = null;
@Prop() textTitle?: string;
@Prop() textDescription: string = null;
@Prop() url?: string;
@Prop() ariaLabel?: string;
@Prop() isExternal: boolean = false;
render() {
const classAttributes = [
"hy-link-box",
this.imageUrl ? "hy-link-box--with-image" : null
].join(" ");
const iconClassAttributes = [
"hy-link-box__link-icon",
this.isExternal ? "hy-link-box__link-icon--external" : null
].join(" ");
const target = this.isExternal ? "_blank" : "_self";
return (
<a
aria-label={this.ariaLabel}
class={classAttributes}
href={this.url}
target={target}
>
{ this.imageUrl &&
<div class="hy-link-box__image-container">
<img aria-hidden="true" src={this.imageUrl} alt={this.imageAlt} />
</div>
}
<div class="hy-link-box__text-container">
<div class="hy-link-box__text-container__title">{ this.textTitle }</div>
{ this.textDescription &&
<div class="hy-link-box__text-container__description">{ this.textDescription }</div>
}
</div>
<span class={iconClassAttributes}>
<hy-icon icon={'hy-icon-arrow-right'} size={16} />
</span>
</a>
);
}
}