All files / src/display Anchor.ts

100% Statements 30/30
100% Branches 2/2
100% Functions 2/2
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 31125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x  
import { LitElement, TemplateResult, html, css } from 'lit';
import { property } from 'lit/decorators.js';
 
export class Anchor extends LitElement {
  static get styles() {
    return css`
      :host {
        color: var(--color-link-primary);
        display: inline-block;
      }
 
      slot:hover {
        cursor: pointer;
        text-decoration: underline;
      }
    `;
  }
 
  @property({ type: String })
  href: string;
 
  private handleClick(evt: MouseEvent) {
    // TODO: fire event instead to be handled upstream
    (window as any).goto(evt);
  }
 
  public render(): TemplateResult {
    return html`<slot href="${this.href}" @click="${this.handleClick}"></slot>`;
  }
}