diff --git a/src/app/GlobalHeader.js b/src/app/GlobalHeader.js index 375b822..2571f8a 100644 --- a/src/app/GlobalHeader.js +++ b/src/app/GlobalHeader.js @@ -154,6 +154,12 @@ function UserNavBarSection() { } } +/** + * Renders the given children as a dropdown menu or as a list + * of buttons, depending on the screen size. + * + * It actually renders both, and shows/hides them by media query! + */ function NavLinksList({ children }) { return ( <> @@ -163,27 +169,27 @@ function NavLinksList({ children }) { } /> - {React.Children.map(children, (c) => - React.cloneElement(c, { listVariant: "menu" }) - )} + {React.Children.map(children, (c) => ( + + ))} - {React.Children.map(children, (c) => - React.cloneElement(c, { listVariant: "buttons" }) - )} + {React.Children.map(children, (c) => ( + + ))} ); } -function NavLinkItem({ listVariant, ...props }) { - if (listVariant === "menu") { - return ; - } else { - return ; - } +function NavLinkItem() { + throw new Error( + `NavLinkItem should only be rendered in a NavLinksList, which should ` + + `render it as both a MenuItem or NavButton element. That way, we can ` + + `show the best layout depending on a CSS media query!` + ); } const NavButton = React.forwardRef(({ icon, ...props }, ref) => {