diff --git a/.changeset/happy-beans-fry.md b/.changeset/happy-beans-fry.md new file mode 100644 index 000000000..b4e3a1605 --- /dev/null +++ b/.changeset/happy-beans-fry.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": minor +--- + +Migrate Header component from EC to B2BP diff --git a/apps/nextjs-website/react-components/components/Header/Header.helpers.tsx b/apps/nextjs-website/react-components/components/Header/Header.helpers.tsx new file mode 100644 index 000000000..ebe35f94e --- /dev/null +++ b/apps/nextjs-website/react-components/components/Header/Header.helpers.tsx @@ -0,0 +1,33 @@ +import { Stack, useTheme, type Theme } from '@mui/material'; +import { DialogBubbleProps } from '../../types/Header/Header.types'; + +const useStyles = (muiTheme: Theme) => ({ + bubbleContainer: { + transform: 'rotate(180deg)', + position: 'absolute', + marginTop: '42px', + padding: muiTheme.spacing(2), + direction: 'rtl', + textAlign: 'left', + borderRadius: '4px', + }, + bubble: { transform: 'rotate(180deg)' }, +}); + +export const DialogBubble = ({ + children, + ...stackProps +}: DialogBubbleProps) => { + const muiTheme = useTheme(); + const styles = useStyles(muiTheme); + return ( + + + {children} + + + ); +}; diff --git a/apps/nextjs-website/react-components/components/Header/Header.tsx b/apps/nextjs-website/react-components/components/Header/Header.tsx new file mode 100644 index 000000000..d28b07bc9 --- /dev/null +++ b/apps/nextjs-website/react-components/components/Header/Header.tsx @@ -0,0 +1,120 @@ +import Box from '@mui/material/Box'; +import Stack from '@mui/material/Stack'; +import { useEffect, useState } from 'react'; +import { HamburgerMenu } from './components/HamburgerMenu'; +import { Navigation } from './components/Navigation'; +import { HeaderTitle } from './components/Title'; +import { HeaderProps } from '@react-components/types/Header/Header.types'; +import { CtaButtons } from '../common/Common'; +import { BackgroundColor } from '../common/Common.helpers'; + +const Header = ({ + product, + theme, + menu, + ctaButtons, + avatar, + beta, + logo, +}: HeaderProps) => { + const backgroundColor = BackgroundColor(theme); + + const [menuOpen, setMenuOpen] = useState(false); + + const openHeader = () => { + setMenuOpen(true); + }; + + const closeHeader = () => { + setMenuOpen(false); + }; + + useEffect(() => { + window.addEventListener('resize', closeHeader); + + return () => { + window.removeEventListener('resize', closeHeader); + }; + }, []); + + const HeaderCtas = () => { + return ctaButtons && ctaButtons.length > 0 ? ( + + {CtaButtons({ + ctaButtons: ctaButtons.map((CtaButton) => ({ + ...CtaButton, + sx: { width: { md: 'auto', xs: '100%' } }, + })), + theme, + })} + + ) : null; + }; + + return ( + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default Header; diff --git a/apps/nextjs-website/react-components/components/Header/components/HamburgerMenu.tsx b/apps/nextjs-website/react-components/components/Header/components/HamburgerMenu.tsx new file mode 100644 index 000000000..531ac078e --- /dev/null +++ b/apps/nextjs-website/react-components/components/Header/components/HamburgerMenu.tsx @@ -0,0 +1,29 @@ +import CloseIcon from '@mui/icons-material/Close'; +import MenuIcon from '@mui/icons-material/Menu'; + +interface HamburgerMenuProps { + open: boolean; + onOpen: () => void; + onClose: () => void; +} + +export const HamburgerMenu = ({ open, onOpen, onClose }: HamburgerMenuProps) => + open ? ( + + ) : ( +