panelHeader.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import space from 'app/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. padding-right: ${hasButtons ? space(1) : null};
  23. `;
  24. const PanelHeader = styled('div')<Props>`
  25. display: flex;
  26. align-items: center;
  27. justify-content: space-between;
  28. color: ${p => (p.lightText ? p.theme.gray300 : p.theme.gray400)};
  29. font-size: ${p => p.theme.fontSizeSmall};
  30. font-weight: 600;
  31. text-transform: uppercase;
  32. border-bottom: 1px solid ${p => p.theme.border};
  33. border-radius: ${p => p.theme.borderRadius} ${p => p.theme.borderRadius} 0 0;
  34. background: ${p => p.theme.backgroundSecondary};
  35. line-height: 1;
  36. position: relative;
  37. ${getPadding};
  38. `;
  39. export default PanelHeader;