widgetHeader.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled from '@emotion/styled';
  2. import {HeaderTitleLegend} from 'sentry/components/charts/styles';
  3. import QuestionTooltip from 'sentry/components/questionTooltip';
  4. import TextOverflow from 'sentry/components/textOverflow';
  5. import {space} from 'sentry/styles/space';
  6. import {MEPTag} from 'sentry/utils/performance/contexts/metricsEnhancedPerformanceDataContext';
  7. import {
  8. GenericPerformanceWidgetProps,
  9. WidgetDataConstraint,
  10. WidgetDataProps,
  11. } from '../types';
  12. export function WidgetHeader<T extends WidgetDataConstraint>(
  13. props: GenericPerformanceWidgetProps<T> & WidgetDataProps<T>
  14. ) {
  15. const {title, titleTooltip, Subtitle, HeaderActions, InteractiveTitle} = props;
  16. return (
  17. <WidgetHeaderContainer>
  18. <TitleContainer>
  19. <StyledHeaderTitleLegend data-test-id="performance-widget-title">
  20. {InteractiveTitle ? (
  21. <InteractiveTitle {...props} />
  22. ) : (
  23. <TextOverflow>{title}</TextOverflow>
  24. )}
  25. <MEPTag />
  26. {titleTooltip && (
  27. <QuestionTooltip position="top" size="sm" title={titleTooltip} />
  28. )}
  29. </StyledHeaderTitleLegend>
  30. {Subtitle ? <Subtitle {...props} /> : null}
  31. </TitleContainer>
  32. <HeaderActionsContainer>
  33. {HeaderActions && <HeaderActions {...props} />}
  34. </HeaderActionsContainer>
  35. </WidgetHeaderContainer>
  36. );
  37. }
  38. const StyledHeaderTitleLegend = styled(HeaderTitleLegend)`
  39. position: relative;
  40. z-index: initial;
  41. top: -${space(0.5)};
  42. `;
  43. const TitleContainer = styled('div')`
  44. display: flex;
  45. flex-direction: column;
  46. align-items: flex-start;
  47. `;
  48. const WidgetHeaderContainer = styled('div')`
  49. display: flex;
  50. justify-content: space-between;
  51. align-items: flex-start;
  52. gap: ${space(1)};
  53. `;
  54. const HeaderActionsContainer = styled('div')`
  55. display: flex;
  56. align-items: center;
  57. gap: ${space(1)};
  58. `;