-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Performance Profiler: logged-out profiler uses the same compo…
- Loading branch information
Showing
10 changed files
with
125 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 33 additions & 25 deletions
58
client/performance-profiler/components/core-web-vitals-display/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,60 @@ | ||
import { useDesktopBreakpoint } from '@automattic/viewport-react'; | ||
import clsx from 'clsx'; | ||
import { useState } from 'react'; | ||
import { | ||
Metrics, | ||
PerformanceMetricsHistory, | ||
PerformanceMetricsItemQueryResponse, | ||
} from 'calypso/data/site-profiler/types'; | ||
import { CoreWebVitalsAccordion } from '../core-web-vitals-accordion'; | ||
import { CoreWebVitalsAccordionV2 } from '../core-web-vitals-accordion/core-web-vitals-accordion-v2'; | ||
import { MetricTabBar } from '../metric-tab-bar'; | ||
import MetricTabBarV2 from '../metric-tab-bar/metric-tab-bar-v2'; | ||
import { CoreWebVitalsDetails } from './core-web-vitals-details'; | ||
import { CoreWebVitalsDetailsV2 } from './core-web-vitals-details_v2'; | ||
import './style.scss'; | ||
|
||
type CoreWebVitalsDisplayProps = Record< Metrics, number > & { | ||
history: PerformanceMetricsHistory; | ||
audits: Record< string, PerformanceMetricsItemQueryResponse >; | ||
recommendationsRef: React.RefObject< HTMLDivElement > | null; | ||
overallScoreIsTab?: boolean; | ||
showV2?: boolean; | ||
onRecommendationsFilterChange?: ( filter: string ) => void; | ||
}; | ||
|
||
export const CoreWebVitalsDisplay = ( props: CoreWebVitalsDisplayProps ) => { | ||
const defaultTab = props.overallScoreIsTab ? 'overall' : 'fcp'; | ||
const defaultTab = props.showV2 ? 'overall' : 'fcp'; | ||
const [ activeTab, setActiveTab ] = useState< Metrics | null >( defaultTab ); | ||
const isDesktop = useDesktopBreakpoint(); | ||
|
||
if ( isDesktop ) { | ||
return ( | ||
<div className="core-web-vitals-display core-web-vitals-display-v2"> | ||
<MetricTabBarV2 | ||
activeTab={ activeTab ?? defaultTab } | ||
setActiveTab={ setActiveTab } | ||
showOverall={ props.overallScoreIsTab } | ||
{ ...props } | ||
/> | ||
<CoreWebVitalsDetailsV2 activeTab={ activeTab } { ...props } /> | ||
</div> | ||
); | ||
} | ||
const MetricBar = props.showV2 ? MetricTabBarV2 : MetricTabBar; | ||
const CoreWebVitalsDetail = props.showV2 ? CoreWebVitalsDetailsV2 : CoreWebVitalsDetails; | ||
|
||
const Accordion = props.showV2 ? CoreWebVitalsAccordionV2 : CoreWebVitalsAccordion; | ||
|
||
return ( | ||
<div className="core-web-vitals-display"> | ||
<CoreWebVitalsAccordionV2 | ||
activeTab={ activeTab } | ||
setActiveTab={ setActiveTab } | ||
showOverall={ props.overallScoreIsTab } | ||
{ ...props } | ||
> | ||
<CoreWebVitalsDetailsV2 activeTab={ activeTab } { ...props } /> | ||
</CoreWebVitalsAccordionV2> | ||
</div> | ||
<> | ||
{ isDesktop && ( | ||
<div | ||
className={ clsx( 'core-web-vitals-display', { | ||
[ 'core-web-vitals-display-v2' ]: props.showV2, | ||
} ) } | ||
> | ||
<MetricBar | ||
activeTab={ activeTab ?? defaultTab } | ||
setActiveTab={ setActiveTab } | ||
{ ...props } | ||
/> | ||
<CoreWebVitalsDetail activeTab={ activeTab } { ...props } /> | ||
</div> | ||
) } | ||
{ ! isDesktop && ( | ||
<div className="core-web-vitals-display"> | ||
<Accordion activeTab={ activeTab } setActiveTab={ setActiveTab } { ...props }> | ||
<CoreWebVitalsDetail activeTab={ activeTab } { ...props } /> | ||
</Accordion> | ||
</div> | ||
) } | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
font-size: 1rem; | ||
font-weight: 500; | ||
margin-bottom: 8px; | ||
width: fit-content; | ||
} | ||
|
||
.subtitle { | ||
|
Oops, something went wrong.