panelHeader.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import space from 'sentry/styles/space';
  4. type Props = {
  5. /**
  6. * Do not add padding to left and right of the header
  7. */
  8. disablePadding?: boolean;
  9. /**
  10. * Usually we place controls at the right of a panel header, to make the
  11. * spacing between the edges correct we will want less padding on the right.
  12. * Use this when the panel has something such as buttons living there.
  13. */
  14. hasButtons?: boolean;
  15. /**
  16. * Use light text
  17. */
  18. lightText?: boolean;
  19. };
  20. const getPadding = ({disablePadding, hasButtons}: Props) => css`
  21. padding: ${hasButtons ? space(1) : space(2)} ${disablePadding ? 0 : space(2)};
  22. `;
  23. const PanelHeader = styled('div')<Props>`
  24. display: flex;
  25. align-items: center;
  26. justify-content: space-between;
  27. color: ${p => (p.lightText ? p.theme.gray300 : p.theme.gray400)};
  28. font-size: ${p => p.theme.fontSizeSmall};
  29. font-weight: 600;
  30. text-transform: uppercase;
  31. border-bottom: 1px solid ${p => p.theme.border};
  32. border-radius: ${p => p.theme.borderRadius} ${p => p.theme.borderRadius} 0 0;
  33. background: ${p => p.theme.backgroundSecondary};
  34. line-height: 1;
  35. position: relative;
  36. ${getPadding};
  37. `;
  38. export default PanelHeader;