chartPanel.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import styled from '@emotion/styled';
  2. import Panel from 'sentry/components/panels/panel';
  3. import PanelBody from 'sentry/components/panels/panelBody';
  4. import {space} from 'sentry/styles/space';
  5. import {Subtitle} from 'sentry/views/performance/landing/widgets/widgets/singleFieldAreaWidget';
  6. type Props = {
  7. children: React.ReactNode;
  8. button?: JSX.Element;
  9. subtitle?: React.ReactNode;
  10. title?: React.ReactNode;
  11. };
  12. export default function ChartPanel({title, children, button, subtitle}: Props) {
  13. return (
  14. <Panel>
  15. <PanelBody withPadding>
  16. {title && (
  17. <Header>
  18. {title && <ChartLabel>{title}</ChartLabel>}
  19. {button}
  20. </Header>
  21. )}
  22. {subtitle && (
  23. <SubtitleContainer>
  24. <Subtitle>{subtitle}</Subtitle>
  25. </SubtitleContainer>
  26. )}
  27. {children}
  28. </PanelBody>
  29. </Panel>
  30. );
  31. }
  32. const SubtitleContainer = styled('div')`
  33. padding-top: ${space(0.5)};
  34. `;
  35. const ChartLabel = styled('div')`
  36. ${p => p.theme.text.cardTitle}
  37. `;
  38. const Header = styled('div')`
  39. padding: 0 ${space(1)} 0 0;
  40. width: 100%;
  41. display: flex;
  42. align-items: center;
  43. justify-content: space-between;
  44. `;