-
Notifications
You must be signed in to change notification settings - Fork 2k
Stats-30 - Ensure correct logo and titles are displayed in the new header #102833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eb54b5a
9fbea44
d7ac13c
aa786c3
4ca4ac9
0380512
d83cf73
22c25bf
af68585
d78644f
6d16e67
70f360f
b908c59
2181bcd
9b3a9ad
0ee8be3
9bb3316
1c04ce2
a35308c
388d76b
f88d7f9
baf967d
3ca2bc2
6985be1
2528130
db51525
a9a5730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,30 +12,35 @@ interface BackLinkProps { | |
|
|
||
| interface HeaderProps extends React.HTMLAttributes< HTMLElement > { | ||
| title?: string; | ||
| titleLogo?: ReactNode; | ||
| backLinkProps?: BackLinkProps; | ||
| titleElement?: ReactNode; | ||
| headElement?: ReactNode; | ||
| children?: ReactNode; | ||
| rightSection?: ReactNode; | ||
| hasScreenOptionsTab?: boolean; | ||
| titleProps?: { | ||
| title?: string; | ||
| titleLogo?: ReactNode; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Header component that can be used in various contexts | ||
| * @param props - Component props | ||
| * @param props.className - Additional CSS class name for the component | ||
| * @param props.title - Header title text | ||
| * @param props.titleProps - Header title props | ||
| * @param props.backLinkProps - Object containing back link properties (backLink URL, backLinkText, and onBackClick handler) | ||
| * @param props.titleElement - Custom element to override default title rendering | ||
| * @param props.headElement - Custom element to override default head section rendering | ||
| * @param props.children - Child elements to render in the right section | ||
| * @param props.rightSection - Child elements to render in the right section | ||
| * @param props.hasScreenOptionsTab - Indicates whether the screen options tab should be added | ||
| * @returns The rendered NavigationHeader component | ||
| */ | ||
| const NavigationHeader: React.FC< HeaderProps > = ( { | ||
| className, | ||
| title, | ||
| titleProps, | ||
| backLinkProps, | ||
| titleElement = <h1 className="calypso-navigation-header__title">{ title }</h1>, | ||
| titleElement, | ||
| headElement = backLinkProps?.url && ( | ||
| <a | ||
| className="calypso-navigation-header__back-link" | ||
|
|
@@ -50,10 +55,27 @@ const NavigationHeader: React.FC< HeaderProps > = ( { | |
| ← { backLinkProps?.text ?? translate( 'Back' ) } | ||
| </a> | ||
| ), | ||
| children, | ||
| rightSection, | ||
| hasScreenOptionsTab, | ||
| ...rest | ||
| } ) => { | ||
| const defaultTitleElement = ( | ||
| <h1 className="calypso-navigation-header__title"> | ||
| { titleProps?.titleLogo && ( | ||
| <span className="calypso-navigation-header__title-logo" aria-hidden="true"> | ||
| { titleProps.titleLogo } | ||
| </span> | ||
| ) } | ||
| { titleProps?.title && titleProps?.titleLogo ? ( | ||
| <span className="calypso-navigation-header__title-text">{ titleProps?.title }</span> | ||
| ) : ( | ||
| titleProps?.title | ||
| ) } | ||
| </h1> | ||
| ); | ||
|
|
||
| const finalTitleElement = titleElement ?? defaultTitleElement; | ||
|
|
||
| return ( | ||
| <header | ||
| className={ clsx( 'calypso-navigation-header', className, { | ||
|
|
@@ -63,8 +85,10 @@ const NavigationHeader: React.FC< HeaderProps > = ( { | |
| > | ||
| <div className="calypso-navigation-header__head">{ headElement }</div> | ||
| <div className="calypso-navigation-header__body"> | ||
| <div className="calypso-navigation-header__left-section">{ titleElement }</div> | ||
| <div className="calypso-navigation-header__right-section">{ children }</div> | ||
| <div className="calypso-navigation-header__left-section">{ finalTitleElement }</div> | ||
| { rightSection && ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the original component design, I feel like the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <div className="calypso-navigation-header__right-section">{ rightSection }</div> | ||
| ) } | ||
| </div> | ||
| </header> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import config from '@automattic/calypso-config'; | ||
| import JetpackLogo from 'calypso/components/jetpack-logo'; | ||
| import NavigationHeaderImpr from 'calypso/components/navigation-header/navigation-header'; | ||
| import { STATS_PRODUCT_NAME, STATS_PRODUCT_NAME_IMPR } from '../../constants'; | ||
|
|
||
| function PageHeader() { | ||
| const isOdysseyStats = config.isEnabled( 'is_running_in_jetpack_site' ); | ||
|
|
||
| if ( isOdysseyStats ) { | ||
| return ( | ||
| <NavigationHeaderImpr | ||
| className="stats__section-header modernized-header" | ||
| titleProps={ { | ||
| title: STATS_PRODUCT_NAME, | ||
| titleLogo: <JetpackLogo size={ 24 } monochrome={ false } />, | ||
| } } | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <NavigationHeaderImpr | ||
| className="stats__section-header modernized-header" | ||
| titleProps={ { | ||
| title: STATS_PRODUCT_NAME_IMPR, | ||
| } } | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default PageHeader; |
Uh oh!
There was an error while loading. Please reload this page.