All files / table styled-components.js

97.5% Statements 39/40
50% Branches 2/4
93.75% Functions 15/16
97.3% Lines 36/37

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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196                      3x 6x                           3x 6x   3x           3x     6x                   3x 6x   3x   3x 34x                                       3x 34x   3x   3x 4x                                 3x 6x               3x 6x   3x   3x         3x 18x   3x   3x 90x                       3x 90x   3x   3x                 3x                     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 * as React from 'react';
 
import {styled} from '../styles/index.js';
 
const StyledTableElement = styled<{}>('div', ({$theme}) => {
  return {
    ...$theme.borders.border300,
    backgroundColor: $theme.colors.tableBackground,
    borderTopLeftRadius: $theme.borders.radius200,
    borderTopRightRadius: $theme.borders.radius200,
    borderBottomRightRadius: $theme.borders.radius200,
    borderBottomLeftRadius: $theme.borders.radius200,
    display: 'flex',
    flexDirection: 'column',
    height: '100%',
    overflowX: 'scroll',
  };
});
 
export const StyledTable = (props: *) => (
  <StyledTableElement role="grid" {...props} />
);
StyledTable.__STYLETRON__ = StyledTableElement.__STYLETRON__;
 
type HorizontalStyleProps = {
  $width?: string,
};
 
const StyledHeadElement = styled<HorizontalStyleProps>(
  'div',
  ({$theme, $width}) => {
    return {
      backgroundColor: $theme.colors.tableHeadBackgroundColor,
      boxShadow: $theme.lighting.shadow400,
      display: 'flex',
      flexGrow: 0,
      width: $width ? $width : '100%',
    };
  },
);
 
export const StyledHead = (props: *) => (
  <StyledHeadElement role="row" {...props} />
);
StyledHead.__STYLETRON__ = StyledHeadElement.__STYLETRON__;
 
const StyledHeadCellElement = styled<{}>('div', ({$theme}) => {
  return {
    ...$theme.typography.font350,
    ...$theme.borders.border300,
    borderTop: 'none',
    borderBottom: 'none',
    borderLeft: 'none',
    color: $theme.colors.colorPrimary,
    display: 'flex',
    justifyContent: 'space-between',
    paddingTop: $theme.sizing.scale500,
    paddingRight: $theme.sizing.scale600,
    paddingBottom: $theme.sizing.scale500,
    paddingLeft: $theme.sizing.scale600,
    width: '100%',
    ':last-of-type': {
      borderRight: 'none',
    },
  };
});
 
export const StyledHeadCell = (props: *) => (
  <StyledHeadCellElement role="columnheader" {...props} />
);
StyledHeadCell.__STYLETRON__ = StyledHeadCellElement.__STYLETRON__;
 
export const StyledSortableLabel = styled<{}>('button', ({$theme}) => {
  return {
    ...$theme.typography.font350,
    alignItems: 'center',
    backgroundColor: 'transparent',
    border: 'none',
    color: $theme.colors.colorPrimary,
    display: 'flex',
    padding: 0,
    ':hover:enabled': {
      cursor: 'pointer',
    },
    ':disabled': {
      color: $theme.colors.mono500,
    },
  };
});
 
const StyledBodyElement = styled<HorizontalStyleProps>('div', ({$width}) => {
  return ({
    width: $width ? $width : '100%',
    overflowX: 'hidden',
    overflowY: 'overlay',
    flex: 1,
  }: {});
});
 
export const StyledBody = (props: *) => (
  <StyledBodyElement role="rowgroup" {...props} />
);
StyledBody.__STYLETRON__ = StyledBodyElement.__STYLETRON__;
 
const StyledRowElement = styled('div', {
  display: 'flex',
  alignItems: 'center',
});
 
export const StyledRow = (props: *) => (
  <StyledRowElement role="row" {...props} />
);
StyledRow.__STYLETRON__ = StyledRowElement.__STYLETRON__;
 
const StyledCellElement = styled<{}>('div', ({$theme}) => {
  return {
    ...$theme.typography.font300,
    color: $theme.colors.colorPrimary,
    display: 'flex',
    flex: 1,
    paddingTop: $theme.sizing.scale300,
    paddingRight: $theme.sizing.scale600,
    paddingBottom: $theme.sizing.scale300,
    paddingLeft: $theme.sizing.scale600,
  };
});
 
export const StyledCell = (props: *) => (
  <StyledCellElement role="gridcell" {...props} />
);
StyledCell.__STYLETRON__ = StyledCellElement.__STYLETRON__;
 
export const StyledFilterButton = styled('button', {
  backgroundColor: 'transparent',
  border: 'none',
  paddingTop: 'none',
  paddingRight: 'none',
  paddingBottom: 'none',
  paddingLeft: 'none',
});
 
export const StyledFilterContent = styled<{}>('div', ({$theme}) => ({
  ...$theme.borders.border300,
  backgroundColor: $theme.colors.tableFilterBackground,
  borderRight: 'none',
  borderLeft: 'none',
  maxHeight: '196px',
  paddingRight: $theme.sizing.scale600,
  paddingLeft: $theme.sizing.scale600,
  overflow: 'auto',
}));
 
export const StyledFilterHeading = styled<{}>('div', ({$theme}) => ({
  ...$theme.typography.font350,
  color: $theme.colors.tableFilterHeading,
  paddingTop: $theme.sizing.scale500,
  paddingRight: $theme.sizing.scale600,
  paddingBottom: $theme.sizing.scale500,
  paddingLeft: $theme.sizing.scale600,
}));
 
export const StyledFilterFooter = styled<{}>('div', ({$theme}) => ({
  backgroundColor: $theme.colors.tableFilterFooterBackground,
  paddingTop: $theme.sizing.scale300,
  paddingRight: $theme.sizing.scale100,
  paddingBottom: $theme.sizing.scale300,
  paddingLeft: $theme.sizing.scale100,
  display: 'flex',
  justifyContent: 'space-between',
  minWidth: '216px',
}));
 
export const StyledAction = styled<{}>('button', ({$theme}) => {
  return {
    backgroundColor: 'transparent',
    border: 'none',
    color: $theme.colors.primary,
    paddingTop: 0,
    paddingRight: 0,
    paddingBottom: 0,
    paddingLeft: 0,
    marginRight: $theme.sizing.scale100,
    marginLeft: $theme.sizing.scale100,
    ':hover:enabled': {
      cursor: 'pointer',
    },
  };
});