All files / accordion styled-components.js

100% Statements 11/11
55.56% Branches 10/18
100% Functions 3/3
100% Lines 11/11

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                            3x   3x   3x         4x 4x                                               3x 5x 5x             3x       5x 5x                                            
/*
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 {getSvgStyles} from '../icon/styled-components.js';
import type {SharedStylePropsArgT} from './types.js';
 
/**
 * Main component container element
 */
export const Root = styled('div', {});
 
export const PanelContainer = styled('div', {width: '100%'});
 
export const Header = styled<SharedStylePropsArgT>('div', props => {
  const {
    $disabled,
    $expanded,
    $theme: {colors, sizing, typography},
  } = props;
  return {
    ...typography.font450,
    color: colors.colorPrimary,
    cursor: $disabled ? 'not-allowed' : 'pointer',
    background: colors.listHeaderFill,
    paddingTop: sizing.scale600,
    paddingBottom: sizing.scale600,
    paddingLeft: sizing.scale700,
    paddingRight: sizing.scale700,
    marginTop: 0,
    marginBottom: 0,
    marginLeft: 0,
    marginRight: 0,
    borderBottom: `1px solid ${$expanded ? colors.mono500 : colors.mono400}`,
    position: 'relative',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'space-between',
    ':hover': {
      color: colors.primary,
    },
  };
});
 
export const ToggleIcon = styled<SharedStylePropsArgT>('svg', props => {
  const {$theme, $disabled, $color} = props;
  return {
    ...getSvgStyles(props),
    color: $color || $theme.colors.foreground,
    cursor: $disabled ? 'not-allowed' : 'pointer',
  };
});
 
export const Content = styled<SharedStylePropsArgT>('div', props => {
  const {
    $theme: {animation, colors, sizing, typography},
    $expanded,
  } = props;
  return {
    ...typography.font300,
    backgroundColor: colors.listBodyFill,
    color: colors.foreground,
    paddingTop: $expanded ? sizing.scale800 : 0,
    paddingBottom: $expanded ? sizing.scale1000 : 0,
    paddingLeft: sizing.scale800,
    paddingRight: sizing.scale800,
    marginTop: 0,
    marginBottom: 0,
    marginLeft: 0,
    marginRight: 0,
    borderBottom: $expanded ? `1px solid ${colors.border}` : 'none',
    boxSizing: 'border-box',
    height: $expanded ? 'auto' : 0,
    maxHeight: $expanded ? '100%' : 0,
    overflow: 'hidden',
    transitionProperty: 'all',
    transitionDuration: animation.timing400,
    transitionTimingFunction: animation.easeInOutCurve,
  };
});