import { useDesktopBreakpoint } from '@automattic/viewport-react'; import clsx from 'clsx'; import { useTranslate } from 'i18n-calypso'; import Markdown from 'react-markdown'; import { PerformanceMetricsItemQueryResponse } from 'calypso/data/site-profiler/types'; import { highImpactAudits } from 'calypso/performance-profiler/utils/metrics'; interface InsightHeaderProps { data: PerformanceMetricsItemQueryResponse; index: number; } export const InsightHeader: React.FC< InsightHeaderProps > = ( props ) => { const isMobile = ! useDesktopBreakpoint(); const translate = useTranslate(); const { data, index } = props; const title = data.title ?? ''; const value = data.displayValue ?? ''; const { id, type } = data; const renderBadge = () => { if ( ! highImpactAudits.includes( id ) ) { return null; } return ( { translate( 'High Impact' ) } ); }; return (
{ index + 1 }
{ props.children }

; }, code( props ) { return { props.children }; }, } } > { title }
{ value && isMobile && ( { value } ) } { value && ! isMobile && (  −  { value } ) } { renderBadge() }
); };