All files / tabs styled-components.js

100% Statements 15/15
87.5% Branches 14/16
100% Functions 4/4
100% Lines 15/15

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90                        2x 10x 10x             2x           36x 36x                                 36x 34x                   36x       2x       10x 10x                   2x       30x 30x                  
/*
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 {ORIENTATION} from './constants.js';
import type {SharedStylePropsArgT} from './types.js';
 
// $FlowFixMe https://github.com/facebook/flow/issues/7745
export const Root = styled<SharedStylePropsArgT>('div', props => {
  const {$orientation} = props;
  return {
    display: 'flex',
    flexDirection: $orientation === ORIENTATION.vertical ? 'row' : 'column',
  };
});
 
// $FlowFixMe https://github.com/facebook/flow/issues/7745
export const Tab = styled<SharedStylePropsArgT>('div', props => {
  const {
    $disabled,
    $active,
    $orientation,
    $theme: {colors, sizing, typography},
  } = props;
  let style = {
    ...typography.font300,
    boxSizing: 'border-box',
    color: $active ? colors.colorPrimary : colors.tabColor,
    cursor: $disabled ? 'not-allowed' : 'pointer',
    paddingTop: sizing.scale600,
    paddingBottom: sizing.scale600,
    paddingLeft: sizing.scale300,
    paddingRight: sizing.scale300,
    marginLeft: sizing.scale200,
    marginRight: sizing.scale200,
    borderBottom:
      $orientation === ORIENTATION.horizontal && $active
        ? `2px solid ${colors.primary400}`
        : 'none',
    display: 'inline-block',
  };
  if (!$disabled) {
    style = {
      ...style,
      ':focus': {
        color: colors.primary400,
      },
      ':hover': {
        color: colors.primary400,
      },
    };
  }
  return style;
});
 
// $FlowFixMe https://github.com/facebook/flow/issues/7745
export const TabBar = styled<SharedStylePropsArgT>('div', props => {
  const {
    $orientation,
    $theme: {colors, sizing},
  } = props;
  return {
    display: 'flex',
    flexDirection: $orientation === ORIENTATION.vertical ? 'column' : 'row',
    paddingLeft: sizing.scale400,
    paddingRight: sizing.scale400,
    backgroundColor: colors.tabBarFill,
  };
});
 
// $FlowFixMe https://github.com/facebook/flow/issues/7745
export const TabContent = styled<SharedStylePropsArgT>('div', props => {
  const {
    $active,
    $theme: {sizing, typography},
  } = props;
  return {
    ...typography.font400,
    display: $active ? 'block' : 'none',
    paddingLeft: sizing.scale800,
    paddingRight: sizing.scale800,
    paddingTop: sizing.scale500,
    paddingBottom: sizing.scale500,
  };
});