All files / src Icon.tsx

71.42% Statements 10/14
44.44% Branches 4/9
100% Functions 2/2
71.42% Lines 10/14

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 33 34 35 36 37 38 39 40 41 42 43 441x                     6x   6x   6x   6x       6x     1x 3x 3x   3x                              
import * as React from 'react'
 
export type IconSize = 'sm' | 'md' | 'lg' | 'tool'
 
export interface IconProps {
  name: string
  size?: IconSize
  style?: React.CSSProperties
}
 
function getSize(size?: IconSize): number {
  Iif (size === 'sm') {
    return 16
  } else Iif (size === 'md') {
    return 24
  } else Iif (size === 'lg') {
    return 32
  } else Iif (size === 'tool') {
    return 26
  }
 
  return 24
}
 
export function Icon({
  children,
  ...props
}: React.PropsWithChildren<IconProps>) {
  return React.isValidElement(children)
    ? React.cloneElement(children, {
        'aria-hidden': true,
        'data-qa': `ci-${props.name}`,
        ...props,
        width: getSize(props.size),
        height: getSize(props.size),
        focusable: false,
        style: {
          ...props.style,
          flex: '0 0 auto',
        },
      })
    : null
}