Skip to content
Snippets Groups Projects
link-box.tsx 1.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • import {Component, ComponentInterface, Prop, h} from '@stencil/core';
    
    
    @Component({
      tag: 'hy-link-box',
      styleUrl: 'link-box.scss',
    
    })
    export class LinkBox implements ComponentInterface {
      @Prop() imageUrl: string = null;
      @Prop() imageAlt: string = null;
      @Prop() textTitle?: string;
      @Prop() textDescription: string = null;
      @Prop() url?: 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(' ');
    
          <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>
    
            <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>
        );
      }
    }