miniChartPanel.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import styled from '@emotion/styled';
  2. import Panel from 'sentry/components/panels/panel';
  3. import {space} from 'sentry/styles/space';
  4. import textStyles from 'sentry/styles/text';
  5. type Props = {
  6. children: React.ReactNode;
  7. button?: JSX.Element;
  8. subtitle?: string;
  9. title?: string;
  10. };
  11. export default function MiniChartPanel({title, children, button, subtitle}: Props) {
  12. return (
  13. <Panel>
  14. <PanelBody>
  15. {(title || button || subtitle) && (
  16. <HeaderContainer>
  17. <Header>
  18. {title && <ChartLabel>{title}</ChartLabel>}
  19. {button}
  20. </Header>
  21. {subtitle && <Subtitle>{subtitle}</Subtitle>}
  22. </HeaderContainer>
  23. )}
  24. {children}
  25. </PanelBody>
  26. </Panel>
  27. );
  28. }
  29. const ChartLabel = styled('p')`
  30. ${p => p.theme.text.cardTitle}
  31. `;
  32. const HeaderContainer = styled('div')`
  33. padding: 0 ${space(1)} ${space(1)} 0;
  34. `;
  35. const Header = styled('div')`
  36. min-height: 24px;
  37. width: 100%;
  38. display: flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. `;
  42. const PanelBody = styled('div')`
  43. padding: ${space(1.5)} ${space(2)};
  44. ${textStyles};
  45. `;
  46. const Subtitle = styled('span')`
  47. color: ${p => p.theme.gray300};
  48. font-size: ${p => p.theme.fontSizeMedium};
  49. display: inline-block;
  50. `;