All files / icon styled-components.js

87.5% Statements 7/8
90% Branches 9/10
100% Functions 1/1
87.5% Lines 7/8

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                                  167x 50x   50x 49x     117x   167x                 27x  
/*
Copyright (c) 2018-2019 Uber Technologies, Inc.
 
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
 
import {styled} from '../styles/index.js';
import type {ThemeT} from '../styles/types.js';
import type {StyledComponentArgsT} from './types.js';
 
export function getSvgStyles({
  $theme,
  $size,
  $color,
}: StyledComponentArgsT & {$theme: ThemeT}) {
  if ($size) {
    Iif ($theme.sizing.hasOwnProperty($size)) {
      $size = $theme.sizing[$size];
    } else if (typeof $size === 'number') {
      $size = `${$size}px`;
    }
  } else {
    $size = $theme.sizing.scale600;
  }
  return {
    display: 'inline-block',
    fill: $color || 'currentColor',
    color: $color || 'currentColor',
    height: $size,
    width: $size,
  };
}
 
export const Svg = styled<StyledComponentArgsT>('svg', getSvgStyles);