table.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import styled from '@emotion/styled';
  2. import space from 'sentry/styles/space';
  3. type TableCellProps = {
  4. align: 'left' | 'right' | 'center';
  5. tabularFigures: boolean;
  6. morePadding?: boolean;
  7. };
  8. const TableOuter = styled('div')`
  9. width: 100%;
  10. margin: ${space(2)} 0;
  11. overflow: hidden;
  12. border: solid 1px ${p => p.theme.border};
  13. border-radius: 4px;
  14. `;
  15. const TableInner = styled('table')`
  16. width: 100%;
  17. margin: 0;
  18. `;
  19. export const Table = ({children}) => (
  20. <TableOuter>
  21. <TableInner>{children}</TableInner>
  22. </TableOuter>
  23. );
  24. export const TableHead = styled('thead')`
  25. background: ${p => p.theme.bodyBackground};
  26. border-bottom: solid 1px ${p => p.theme.border};
  27. `;
  28. export const TableHeadCell = styled('th')<TableCellProps>`
  29. font-size: 0.875em;
  30. color: ${p => p.theme.subText};
  31. padding: ${space(1)} 0;
  32. text-transform: uppercase;
  33. ${p => p.align && `text-align: ${p.align};`}
  34. ${p => p.tabularFigures && `font-variant-numeric: tabular-nums;`}
  35. &:first-of-type {
  36. padding-left: ${space(2)};
  37. }
  38. &:last-of-type {
  39. padding-right: ${space(2)};
  40. }
  41. & * {
  42. margin: 0;
  43. }
  44. `;
  45. export const TableBody = styled('tbody')``;
  46. export const TableRow = styled('tr')`
  47. &:not(:last-child) {
  48. border-bottom: solid 1px ${p => p.theme.innerBorder};
  49. }
  50. `;
  51. export const TableCell = styled('td')<TableCellProps>`
  52. padding: ${p => (p.morePadding ? space(2) : space(1))} 0;
  53. vertical-align: center;
  54. ${p => p.align && `text-align: ${p.align};`}
  55. ${p => p.tabularFigures && `font-variant-numeric: tabular-nums;`}
  56. &:first-of-type {
  57. padding-left: ${space(2)};
  58. }
  59. &:last-of-type {
  60. padding-right: ${space(2)};
  61. }
  62. & * {
  63. margin: 0;
  64. }
  65. `;