Newer
Older
Ekaterina Kondareva
committed
import {Component, ComponentInterface, Prop, h} from '@stencil/core';
@Component({
tag: 'hy-link-box',
styleUrl: 'link-box.scss',
Ekaterina Kondareva
committed
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;
Ekaterina Kondareva
committed
@Prop() scLabel?: string;
Ekaterina Kondareva
committed
render() {
const classAttributes = ['hy-link-box', this.imageUrl ? 'hy-link-box--with-image' : null].join(' ');
Ekaterina Kondareva
committed
'hy-link-box__link-icon',
this.isExternal ? 'hy-link-box__link-icon--external' : null
].join(' ');
Ekaterina Kondareva
committed
const target = this.isExternal ? '_blank' : '_self';
Ekaterina Kondareva
committed
<a aria-label={this.scLabel} 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>
Ekaterina Kondareva
committed
)}
Ekaterina Kondareva
committed
<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>
);
}
}