miniChartPanel.tsx 1.2 KB

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