All files / tooltip styled-components.js

50% Statements 3/6
100% Branches 0/0
0% Functions 0/3
100% Lines 3/3

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                                                      3x                   3x                     3x        
/*
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 {
  getBodyStyles,
  getArrowStyles,
  getInnerStyles,
} from '../popover/styled-components.js';
import {getEndPosition} from '../popover/utils.js';
import type {SharedStylePropsArgT} from '../popover/types.js';
 
/**
 * We want to reuse the default Popover styles and add our overrides
 * for Tooltip. Normally you could do something like
 * withStyleDeep(StyledPopoverBody, {...}), however this break the
 * ability to use $style properly–the style overrides passed in by
 * the customer will override the base styles but not the styles
 * specified here.
 *
 * We could create our own withStyleDeep that also takes the $style
 * prop into account
 */
export const Body = styled<SharedStylePropsArgT>('div', props => ({
  ...getBodyStyles(props),
  backgroundColor: props.$theme.colors.tooltipBackground,
  boxShadow: props.$theme.lighting.shadow400,
  color: props.$theme.colors.tooltipText,
  // Reset transition property to opacity only, and static transform
  transitionProperty: 'opacity',
  transform: getEndPosition(props.$popoverOffset),
}));
 
export const Inner = styled<SharedStylePropsArgT>('div', props => ({
  ...getInnerStyles(props),
  backgroundColor: props.$theme.colors.tooltipBackground,
  paddingTop: props.$theme.sizing.scale300,
  paddingBottom: props.$theme.sizing.scale300,
  paddingLeft: props.$theme.sizing.scale300,
  paddingRight: props.$theme.sizing.scale300,
  ...props.$theme.typography.font250,
  color: props.$theme.colors.tooltipText,
}));
 
export const Arrow = styled<SharedStylePropsArgT>('div', props => ({
  ...getArrowStyles(props),
  backgroundColor: props.$theme.colors.tooltipBackground,
}));