All files / components/Link Link.svelte

100% Statements 32/32
100% Branches 4/4
100% Functions 0/0
100% Lines 32/32

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 31 32 331x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
<script lang="ts">
  import classNames from "$lib/util/classNames";
  import "./Link.scss";
 
  // Note: All props not mentioned below will be passed directly to the <a/> element via $$props, e.g. href and target.
  interface $$Props extends Partial<HTMLAnchorElement> {
    class?: string;
    external?: boolean;
    alternate?: boolean;
  }
 
  // this isn't necessary but will suppress vite-plugin-svelte a11y warnings
  export let href = "";
  // additional classes to add
  let className = "";
  export { className as class };
  // render as an external link, with the "launch" icon rendered ::after
  export let external = false;
  // render with the alternate variation, for use on darker backgrounds
  export let alternate = false;
 
  $: linkClassNames = classNames(
    `usa-link`,
    external && "usa-link--external",
    alternate && "usa-link--alt",
    className
  );
</script>
 
<a {...$$restProps} {href} class={linkClassNames} rel={external ? "external" : null}>
  <slot />
</a>