Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP(ui-top-nav-bar): extract rendering logic into a constant
Browse files Browse the repository at this point in the history
joyenjoyer committed Nov 2, 2023
1 parent f5531b8 commit ba90489
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -123,7 +123,6 @@ class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {

get hasBreadcrumbBlock() {
const { renderBreadcrumb } = this.props
// TODO: check the children part
return (
!!renderBreadcrumb &&
React.Children.count(renderBreadcrumb.props.children) > 0
@@ -141,6 +140,10 @@ class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
styles
} = this.props

// only render breadcrumb if there is no brand or menu items
const shouldRenderBreadcrumbBlock =
!(this.hasBrandBlock || this.hasMenuItemsBlock) && this.hasBreadcrumbBlock

return (
<nav
{...omitProps(this.props, allowedProps)}
@@ -156,9 +159,7 @@ class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
<div css={styles?.menuItemsContainer}>{renderMenuItems}</div>
)}

{!(this.hasBrandBlock || this.hasMenuItemsBlock) &&
this.hasBreadcrumbBlock &&
renderBreadcrumb}
{shouldRenderBreadcrumbBlock && renderBreadcrumb}

{this.hasActionItemsBlock && (
<div css={styles?.actionItemsContainer}>{renderActionItems}</div>

0 comments on commit ba90489

Please sign in to comment.