keyValueTable.tsx 965 B

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