Newer
Older
import { Component, ComponentInterface, Prop, h } from '@stencil/core';
@Component({
tag: 'hy-standalone-link',
styleUrl: 'standalone-link.scss',
Ekaterina Kondareva
committed
shadow: false,
})
export class StandaloneLink implements ComponentInterface {
Ekaterina Kondareva
committed
@Prop() linkContent: string = '';
@Prop() url?: string;
@Prop() ariaLabel?: string;
@Prop() isExternal: boolean = false;
@Prop() isEnabled: boolean = true;
Ekaterina Kondareva
committed
const containerClassAttributes = ["hy-standalone-link-container"].join(" ");
const classAttributes = ["hy-standalone-link",
this.isEnabled ? "enabled" : "disabled"
];
Ekaterina Kondareva
committed
const textClassAttributes = ["hy-standalone-link__text"].join(" ");
const iconClassAttributes = [
"hy-standalone-link__link-icon",
this.isExternal ? "hy-standalone-link__link-icon--external" : null
].join(" ");
Ekaterina Kondareva
committed
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}
Ekaterina Kondareva
committed
<span class={iconClassAttributes}>
<hy-icon icon={'hy-icon-arrow-right'} size={16} />
</span>
</a>
</span>
);