chartPanel.tsx 1.2 KB

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