miniChartPanel.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. <HeaderContainer>
  16. <Header>
  17. {title && <ChartLabel>{title}</ChartLabel>}
  18. {button}
  19. </Header>
  20. {subtitle && <Subtitle>{subtitle}</Subtitle>}
  21. </HeaderContainer>
  22. {children}
  23. </PanelBody>
  24. </Panel>
  25. );
  26. }
  27. const ChartLabel = styled('p')`
  28. ${p => p.theme.text.cardTitle}
  29. `;
  30. const HeaderContainer = styled('div')`
  31. padding: 0 ${space(1)} ${space(1)} 0;
  32. `;
  33. const Header = styled('div')`
  34. min-height: 24px;
  35. width: 100%;
  36. display: flex;
  37. align-items: center;
  38. justify-content: space-between;
  39. `;
  40. const PanelBody = styled('div')`
  41. padding: ${space(1.5)} ${space(2)};
  42. ${textStyles};
  43. `;
  44. const Subtitle = styled('span')`
  45. color: ${p => p.theme.gray300};
  46. font-size: ${p => p.theme.fontSizeMedium};
  47. display: inline-block;
  48. `;