Skip to content

Commit

Permalink
hide header in list if empty (#6440)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanL authored Aug 29, 2023
1 parent e03891c commit 21b9a55
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions frontend/src/app/commonComponents/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,36 @@ const Header: React.FC<{}> = () => {
key: "patient-nav-link",
},
];
const mainNavList = (deviceType: string) =>
mainNavContent.map((item) => {
const mainNavList = (deviceType: "desktop" | "mobile") => {
let navList = mainNavContent
.map((item) => {
return (
item.displayPermissions && (
<li key={item.key} className="usa-nav__primary-item">
<LinkWithQuery
to={item.url}
onClick={() => setMenuVisible(false)}
className={item.className}
id={`${deviceType}-${item.key}`}
>
{item.displayText}
</LinkWithQuery>
</li>
)
);
})
.filter((item) => item);
if (deviceType === "mobile" && navList?.length > 0) {
return (
<li key={item.key} className="usa-nav__primary-item">
{item.displayPermissions ? (
<LinkWithQuery
to={item.url}
onClick={() => setMenuVisible(false)}
className={item.className}
id={`${deviceType}-${item.key}`}
>
{item.displayText}
</LinkWithQuery>
) : null}
</li>
<ul className="usa-nav__primary usa-accordion mobile-main-nav-container">
{navList}
</ul>
);
});
} else if (deviceType === "desktop" && navList?.length > 0) {
return <ul className="usa-nav__primary usa-accordion">{navList}</ul>;
}
};

const secondaryNavContent = [
{
url: "#",
Expand Down Expand Up @@ -331,9 +344,7 @@ const Header: React.FC<{}> = () => {
>
<FontAwesomeIcon icon={"window-close"} />
</button>
<ul className="usa-nav__primary usa-accordion mobile-main-nav-container">
{mainNavList("mobile")}
</ul>
{mainNavList("mobile")}
<ul className="usa-nav__primary usa-accordion mobile-secondary-nav-container">
{secondaryNav("mobile")}
</ul>
Expand Down Expand Up @@ -365,9 +376,7 @@ const Header: React.FC<{}> = () => {
aria-label="Primary navigation"
className="usa-nav prime-nav desktop-nav"
>
<ul className="usa-nav__primary usa-accordion">
{mainNavList("desktop")}
</ul>
{mainNavList("desktop")}
{facilities && facilities.length > 0 ? (
<div className="prime-facility-select">
<Dropdown
Expand Down

0 comments on commit 21b9a55

Please sign in to comment.