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> ); } }