All files / components/Icon Icon.svelte

100% Statements 27/27
33.33% Branches 1/3
100% Functions 0/0
100% Lines 27/27

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 281x 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  
<svelte:options immutable />
 
<script lang="ts">
  import classNames from "$lib/util/classNames";
 
  // Size is taken from the USWDS implemention of icons in their icon component package (see
  // https://designsystem.digital.gov/components/icon/#using-the-icon-component-2 for more details).
  // Reason for undefined `size` value to start: "By default, icons will scale with font size.
  // If you want to specify an icon size, use one of the component’s size variants."
  export let size: 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined = undefined;
 
  let className = "";
  export { className as class };
 
  export let alt = "";
  export let src: string;
  export let plain = false;
 
  if (plain && size) console.warn('"size" prop has no effect when "plain" is set');
</script>
 
<img
  {...$$restProps}
  class={classNames(!plain && "usa-icon", !plain && size && `usa-icon--size-${size}`, className)}
  {src}
  {alt}
/>