keyValueTable.tsx 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import styled from '@emotion/styled';
  3. import overflowEllipsis from 'app/styles/overflowEllipsis';
  4. import space from 'app/styles/space';
  5. import {Theme} from 'app/utils/theme';
  6. type Props = {
  7. keyName: React.ReactNode;
  8. value: React.ReactNode;
  9. };
  10. export const KeyValueTable = styled('dl')`
  11. display: grid;
  12. grid-template-columns: 50% 50%;
  13. `;
  14. export const KeyValueTableRow = ({keyName, value}: Props) => {
  15. return (
  16. <React.Fragment>
  17. <Key>{keyName}</Key>
  18. <Value>{value}</Value>
  19. </React.Fragment>
  20. );
  21. };
  22. const commonStyles = ({theme}: {theme: Theme}) => `
  23. font-size: ${theme.fontSizeMedium};
  24. padding: ${space(0.5)} ${space(1)};
  25. font-weight: normal;
  26. line-height: inherit;
  27. ${overflowEllipsis};
  28. &:nth-of-type(2n-1) {
  29. background-color: ${theme.backgroundSecondary};
  30. }
  31. `;
  32. const Key = styled('dt')`
  33. ${commonStyles};
  34. color: ${p => p.theme.textColor};
  35. `;
  36. const Value = styled('dd')`
  37. ${commonStyles};
  38. color: ${p => p.theme.subText};
  39. text-align: right;
  40. `;