import styled from '@emotion/styled'; import FeatureBadge from 'sentry/components/badge/featureBadge'; import {HeaderTitleLegend} from 'sentry/components/charts/styles'; import QuestionTooltip from 'sentry/components/questionTooltip'; import TextOverflow from 'sentry/components/textOverflow'; import {space} from 'sentry/styles/space'; import {MEPTag} from 'sentry/utils/performance/contexts/metricsEnhancedPerformanceDataContext'; import type { GenericPerformanceWidgetProps, WidgetDataConstraint, WidgetDataProps, } from '../types'; import {PerformanceWidgetSetting} from '../widgetDefinitions'; export function WidgetHeader( props: GenericPerformanceWidgetProps & WidgetDataProps ) { const {title, titleTooltip, Subtitle, HeaderActions, InteractiveTitle, chartSetting} = props; const isWebVitalsWidget = [ PerformanceWidgetSetting.HIGHEST_OPPORTUNITY_PAGES, PerformanceWidgetSetting.OVERALL_PERFORMANCE_SCORE, ].includes(chartSetting); const isCacheWidget = chartSetting === PerformanceWidgetSetting.HIGHEST_CACHE_MISS_RATE_TRANSACTIONS; const featureBadge = isWebVitalsWidget || isCacheWidget ? : null; return ( {InteractiveTitle ? ( ) : ( {title} )} {featureBadge} {titleTooltip && ( )} {Subtitle ? : null} {HeaderActions && } ); } const StyledHeaderTitleLegend = styled(HeaderTitleLegend)` position: relative; z-index: initial; top: -${space(0.5)}; ${FeatureBadge} { position: relative; top: -${space(0.25)}; margin-left: ${space(0.25)}; } `; const TitleContainer = styled('div')` display: flex; flex-direction: column; align-items: flex-start; `; const WidgetHeaderContainer = styled('div')` display: flex; justify-content: space-between; align-items: flex-start; gap: ${space(1)}; `; const HeaderActionsContainer = styled('div')` display: flex; align-items: center; gap: ${space(1)}; `;