File size: 1,438 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import { Gridicon, ScreenReaderText } from '@automattic/components';
import { Button } from '@wordpress/components';
import { translate } from 'i18n-calypso';
import { ReactNode, useState } from 'react';
import NavigationHeader from 'calypso/components/navigation-header';
type MobileHeaderProps = {
pageTitle: string;
pageSelector: JSX.Element;
subtitle?: ReactNode;
};
export const MobileHeader = ( { pageTitle, pageSelector, subtitle }: MobileHeaderProps ) => {
const [ isPageSelectorVisible, setIsPageSelectorVisible ] = useState( false );
const togglePageSelector = () => {
setIsPageSelectorVisible( ! isPageSelectorVisible );
};
return (
<>
<NavigationHeader
className="site-performance__navigation-header"
title={ <div className="navigation-header-title">{ translate( 'Performance' ) }</div> }
subtitle={ pageTitle }
>
<Button
variant="tertiary"
onClick={ togglePageSelector }
aria-expanded={ isPageSelectorVisible }
>
<ScreenReaderText>{ translate( 'toggle page selector' ) }</ScreenReaderText>
<Gridicon icon="cog" />
</Button>
</NavigationHeader>
{ isPageSelectorVisible && (
<div
css={ {
width: '100%',
} }
>
{ pageSelector }
<div
css={ {
marginTop: '20px',
fontSize: '14px',
color: 'var(--color-neutral-50)',
} }
>
{ subtitle }
</div>
</div>
) }
</>
);
};
|