-
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.
Logged-in Performance Profiler: Add Header section (#94460)
* create device tab component * add page selector and device selector to header section * do not show tab
- Loading branch information
Showing
7 changed files
with
166 additions
and
6 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
51 changes: 51 additions & 0 deletions
51
client/site-performance/components/device-tab-control/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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { SegmentedControl } from '@automattic/components'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useState } from 'react'; | ||
|
||
import './style.scss'; | ||
|
||
type DeviceTabControlsProps = { | ||
onDeviceTabChange: ( tab: string ) => void; | ||
}; | ||
|
||
export const DeviceTabControls = ( { onDeviceTabChange }: DeviceTabControlsProps ) => { | ||
const translate = useTranslate(); | ||
const [ selectedOption, setSelectedOption ] = useState( 'mobile' ); | ||
|
||
const handleOptionClick = ( newSelectedOption: string ) => { | ||
setSelectedOption( newSelectedOption ); | ||
|
||
onDeviceTabChange( newSelectedOption ); | ||
}; | ||
|
||
const options = [ | ||
{ | ||
value: 'mobile', | ||
label: translate( 'Mobile' ), | ||
}, | ||
{ | ||
value: 'desktop', | ||
label: translate( 'Desktop' ), | ||
}, | ||
]; | ||
|
||
return ( | ||
<div className="site-performance-device-tab__container"> | ||
<div className="site-performance-device-tab__heading">{ translate( 'Device' ) }</div> | ||
<SegmentedControl className="site-performance-device-tab__controls"> | ||
{ options.map( ( option ) => { | ||
return ( | ||
<SegmentedControl.Item | ||
key={ option.value } | ||
value={ option.value } | ||
selected={ selectedOption === option.value } | ||
onClick={ () => handleOptionClick( option.value ) } | ||
> | ||
{ option.label } | ||
</SegmentedControl.Item> | ||
); | ||
} ) } | ||
</SegmentedControl> | ||
</div> | ||
); | ||
}; |
40 changes: 40 additions & 0 deletions
40
client/site-performance/components/device-tab-control/style.scss
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@import "@wordpress/base-styles/breakpoints"; | ||
@import "@wordpress/base-styles/mixins"; | ||
|
||
.site-performance-device-tab__controls { | ||
flex-grow: 1; | ||
&.segmented-control .segmented-control__item:first-of-type .segmented-control__link { | ||
border-top-left-radius: 4px; | ||
border-bottom-left-radius: 4px; | ||
} | ||
&.segmented-control .segmented-control__item:last-of-type .segmented-control__link { | ||
border-top-right-radius: 4px; | ||
border-bottom-right-radius: 4px; | ||
} | ||
&.segmented-control .segmented-control__item.is-selected .segmented-control__link { | ||
background-color: var(--color-link); | ||
border-color: var(--color-link); | ||
} | ||
@include break-medium { | ||
max-width: 329px; | ||
} | ||
} | ||
|
||
.site-performance-device-tab__container { | ||
display: flex; | ||
justify-content: flex-end; | ||
align-self: flex-start; | ||
flex-direction: column; | ||
gap: 10px; | ||
flex-grow: 1; | ||
@include break-medium { | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
} | ||
|
||
.site-performance-device-tab__heading { | ||
font-weight: 400; | ||
font-size: 0.875rem; | ||
line-height: 20px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { translate } from 'i18n-calypso'; | ||
import InlineSupportLink from 'calypso/components/inline-support-link'; | ||
import NavigationHeader from 'calypso/components/navigation-header'; | ||
import { PageSelector } from './components/PageSelector'; | ||
import { DeviceTabControls } from './components/device-tab-control'; | ||
import './style.scss'; | ||
|
||
export const SitePerformance = () => { | ||
return ( | ||
<div className="site-performance"> | ||
<div className="site-performance-device-tab-controls__container"> | ||
<NavigationHeader | ||
className="site-performance__navigation-header" | ||
title={ translate( 'Performance' ) } | ||
subtitle={ translate( | ||
'Optimize your site for lightning-fast performance. {{link}}Learn more.{{/link}}', | ||
{ | ||
components: { | ||
link: <InlineSupportLink supportContext="site-monitoring" showIcon={ false } />, | ||
}, | ||
} | ||
) } | ||
/> | ||
<PageSelector /> | ||
<DeviceTabControls onDeviceTabChange={ () => {} } /> | ||
</div> | ||
<div>Peformance insights</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@use "sass:math"; | ||
@import "@wordpress/base-styles/breakpoints"; | ||
|
||
$section-max-width: 1224px; | ||
|
||
.site-performance { | ||
padding: 0 max(calc(50% - #{math.div( $section-max-width, 2 )}), 32px); | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
} | ||
|
||
.site-performance-device-tab-controls__container { | ||
display: flex; | ||
gap: 24px; | ||
flex-wrap: wrap; | ||
align-items: start; | ||
justify-content: space-between; | ||
} | ||
|
||
.site-performance__navigation-header.navigation-header { | ||
width: auto; | ||
padding-bottom: 0; | ||
margin-bottom: 16px; | ||
|
||
@media (max-width: $break-medium) { | ||
margin-bottom: 8px; | ||
} | ||
} |