From 104eabbef58c9fa77aaefef22180b859dfd531cb Mon Sep 17 00:00:00 2001 From: Harry Ross Date: Fri, 29 Dec 2023 17:06:08 +1100 Subject: [PATCH] Added subtitle + title fields instead of logo override --- .../MegaMenuLayout/MegaMenuLayout.tsx | 77 +++++++++++-------- src/App.tsx | 5 +- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/lib/components/MegaMenuLayout/MegaMenuLayout.tsx b/lib/components/MegaMenuLayout/MegaMenuLayout.tsx index 6c0c6b8..a8596b5 100644 --- a/lib/components/MegaMenuLayout/MegaMenuLayout.tsx +++ b/lib/components/MegaMenuLayout/MegaMenuLayout.tsx @@ -4,33 +4,40 @@ import { useMenuItems } from "../../hooks/useMenuItems"; import { NavMenuGroup } from "../../types/megamenu"; import { CustomLink } from "../CustomLink"; import DesktopMenu from "../DesktopMenu/DesktopMenu"; -import { Logo as BaseLogo } from "../Logo"; +import { Logo } from "../Logo"; import MobileMenu from "../MobileMenu/MobileMenu"; import { PhoneButton } from "../PhoneButton"; import { Search } from "../Search"; -export interface MegaMenuWrapperProps extends React.PropsWithChildren { - tagline?: string; +export type MegaMenuWrapperProps = { menuBarItems?: NavMenuGroup[]; - logoOverride?: () => JSX.Element; - sideActionsOverride?: () => JSX.Element; - // TODO: REmove - hidePhone?: boolean; -} + subtitle?: string; + rightSideActionsOverride?: () => JSX.Element; +} & React.PropsWithChildren & + (Tagline | Title); + +type Tagline = { + title?: never; + tagline?: string; +}; + +type Title = { + title: string; + tagline?: never; +}; const MegaMenuLayout: React.FC = ({ - tagline = "Enterprise Software Development", + tagline, + title, + subtitle, menuBarItems, - logoOverride, - sideActionsOverride, - hidePhone, + rightSideActionsOverride, }) => { const [isMobileMenuOpen, setMobileMenuOpen] = useState(false); const { menuItems } = useMenuItems(menuBarItems); - const Logo = logoOverride; - const RightSideActions = sideActionsOverride; + const RightSideActions = rightSideActionsOverride; return ( <> @@ -40,30 +47,35 @@ const MegaMenuLayout: React.FC = ({ aria-label="Global" >
- +
- {Logo ? ( - - ) : ( - <> - -
- {tagline} -
- + + + {tagline && ( +
+ {tagline} +
+ )} + {title && ( +
+ {title} +
)}
+ {subtitle && ( +

+ {subtitle} +

+ )}
- {!hidePhone && } - {RightSideActions && ( + {RightSideActions ? (
+ ) : ( + )} @@ -78,7 +90,7 @@ const MegaMenuLayout: React.FC = ({
@@ -88,11 +100,12 @@ const MegaMenuLayout: React.FC = ({ closeMobileMenu={() => setMobileMenuOpen(false)} /> - {!hidePhone && } - {RightSideActions && ( + {RightSideActions ? (
+ ) : ( + )} ); diff --git a/src/App.tsx b/src/App.tsx index 12187d9..f7900ae 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,10 @@ function App() { <>
Test MegaMenu
- +
);