Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MegaMenu - Ready For Review #1571

Merged
merged 7 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/web/assets/menuIcon/roles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 129 additions & 67 deletions packages/web/components/MegaMenu/DesktopNavLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {
Button,
ChevronDownIcon,
ChevronUpIcon,
ExternalLinkIcon,
Flex,
FlexProps,
Icon,
Link,
Menu,
MenuButton,
MenuList,
Expand All @@ -26,74 +28,134 @@ export const DesktopNavLinks: React.FC<FlexProps> = (props) => (
<Menu key={section.label} offset={[0, 0]} preventOverflow placement="top">
{({ isOpen }) => (
<>
<MenuButton
as={Button}
variant="link"
minW="fit-content"
color="white"
fontSize="lg"
fontWeight={700}
textTransform="uppercase"
mx={6}
_expanded={{ color: 'cyan.300' }}
_focus={{ outline: 'none', border: 'none' }}
rightIcon={
isOpen ? (
<ChevronUpIcon color="white" />
) : (
<ChevronDownIcon color="white" />
)
}
>
{section.label}
<Icon
position="absolute"
left="calc(50% - 1.25rem)"
top={14}
w={6}
h={isOpen ? 'auto' : 0}
opacity={isOpen ? 1 : 0}
transition="opacity 0.2s"
zIndex={2}
>
<path
d="M12 0L24 12C14.6274 12 9.37258 12 0 12L12 0Z"
fill="rgba(42, 31, 71, 0.99)"
/>
</Icon>
</MenuButton>
{isOpen && (
<Box
position="absolute"
minW="100vw"
top="5rem"
left="calc(100% - 100vw)"
mx={0}
h="100vh"
bg="linear-gradient(rgba(0,0,0,0.9) 10%, rgba(0,0,0,0) 96%)"
sx={{ filter: 'blur(3rem)' }}
zIndex={-2}
/>
{section.type === 'menu' ? (
<>
<MenuButton
as={Button}
variant="link"
minW="fit-content"
color="white"
fontSize={{ m: 's', lg: 'm', xl: 'lg' }}
fontWeight={700}
textTransform="uppercase"
mx={{ lg: 3, xl: 6 }}
_expanded={{ color: 'cyan.300' }}
_focus={{ outline: 'none', border: 'none' }}
rightIcon={
isOpen ? (
<ChevronUpIcon color="white" />
) : (
<ChevronDownIcon color="white" />
)
}
>
{section.label}
{section.type === 'menu' && (
<Icon
position="absolute"
left="calc(50% - 1.25rem)"
top={14}
w={6}
h={isOpen ? 'auto' : 0}
opacity={isOpen ? 1 : 0}
transition="opacity 0.2s"
zIndex={2}
>
<path
d="M12 0L24 12C14.6274 12 9.37258 12 0 12L12 0Z"
fill="rgba(42, 31, 71, 0.99)"
/>
</Icon>
)}
</MenuButton>
{section.type === 'menu' && isOpen && (
<Box
position="absolute"
minW="100vw"
top="5rem"
left="calc(100% - 100vw)"
mx={0}
h="100vh"
bg="linear-gradient(rgba(0,0,0,0.9) 10%, rgba(0,0,0,0) 96%)"
sx={{ filter: 'blur(3rem)' }}
zIndex={-2}
/>
)}
{section?.menuItems?.length && (
<MenuList
display="grid"
gridTemplateColumns={
section.menuItems.length > 4
? 'repeat(2, 1fr)'
: 'repeat(1, 1fr)'
}
gridGap={2}
w={section.menuItems.length > 4 ? '60rem' : '30rem'}
p={4}
boxShadow="dark-lg"
bg="linear-gradient(180deg, rgba(42, 31, 71, 0.9) 6.18%, rgba(17, 3, 32, 0.86) 140%)"
borderRadius="md"
border={0}
>
{section.menuItems.map((item: MenuLinkItem) => (
<DesktopMenuItem {...item} key={item.title} />
))}
</MenuList>
)}
</>
) : (
<>
<Link
display="flex"
role="group"
href={section?.url}
target={section.type === 'external-link' ? '_blank' : ''}
w="full"
h="full"
alignItems="center"
_focus={{ outline: 'none' }}
>
<MenuButton
as={Button}
variant="link"
minW="fit-content"
color={
section.type === 'external-link' ? '#79F8FB' : 'white'
}
fontSize={{ m: 's', lg: 'm', xl: 'lg' }}
fontWeight={700}
textTransform="uppercase"
mx={{ lg: 3, xl: 6 }}
_expanded={{ color: 'cyan.300' }}
_focus={{ outline: 'none', border: 'none' }}
rightIcon={
section.type === 'external-link' && (
<ExternalLinkIcon color="#79F8FB" />
)
}
>
{section.label}
{section.type === 'menu' && (
<Icon
position="absolute"
left="calc(50% - 1.25rem)"
top={14}
w={6}
h={isOpen ? 'auto' : 0}
opacity={isOpen ? 1 : 0}
transition="opacity 0.2s"
zIndex={2}
>
<path
d="M12 0L24 12C14.6274 12 9.37258 12 0 12L12 0Z"
fill="rgba(42, 31, 71, 0.99)"
/>
</Icon>
)}
</MenuButton>
</Link>
</>
)}
<MenuList
display="grid"
gridTemplateColumns={
section.menuItems.length > 4
? 'repeat(2, 1fr)'
: 'repeat(1, 1fr)'
}
gridGap={2}
w={section.menuItems.length > 4 ? '60rem' : '30rem'}
p={4}
boxShadow="dark-lg"
bg="linear-gradient(180deg, rgba(42, 31, 71, 0.9) 6.18%, rgba(17, 3, 32, 0.86) 140%)"
borderRadius="md"
border={0}
>
{section.menuItems.map((item: MenuLinkItem) => (
<DesktopMenuItem {...item} key={item.title} />
))}
</MenuList>
</>
)}
</Menu>
Expand Down
100 changes: 66 additions & 34 deletions packages/web/components/MegaMenu/MegaMenuHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
BoxedNextImage as Image,
BoxProps,
CloseIcon,
ExternalLinkIcon,
Flex,
HamburgerIcon,
Link,
Expand Down Expand Up @@ -85,7 +86,7 @@ export const MegaMenuHeader: React.FC = () => {
cursor="pointer"
h={8}
w={8}
display={{ base: 'flex', lg: 'none' }}
display={{ base: 'flex', lg: 'flex', xl: 'none' }}
p={2}
my="auto"
>
Expand All @@ -106,6 +107,13 @@ export const MegaMenuHeader: React.FC = () => {
justify="center"
align="center"
pos="relative"
display={{
base: 'none',
sm: 'none',
md: 'none',
lg: 'none',
xl: 'flex',
}}
>
<Logo
link={user ? '/dashboard' : '/'}
Expand Down Expand Up @@ -143,6 +151,13 @@ export const MegaMenuHeader: React.FC = () => {
)}
</Box>
</Flex>
<Logo
display={{ lg: 'flex', xl: 'none' }}
link={user ? '/dashboard' : '/'}
pos={{ base: 'initial', lg: 'absolute' }}
pt={1}
right={4}
/>
</Flex>
<Stack
display={{ base: isOpen ? 'block' : 'none', xl: 'none' }}
Expand All @@ -159,40 +174,57 @@ export const MegaMenuHeader: React.FC = () => {
>
{MenuSectionLinks.map((section) => (
<Stack pt={1} key={section.label}>
<Text fontSize={18} fontWeight={600} textTransform="capitalize">
{section.label}
</Text>
<Link
href={section?.url}
target={section.type === 'external-link' ? '_blank' : ''}
display={'flex'}
flexDir={'row'}
alignItems={'center'}
>
<Text
fontSize={18}
fontWeight={600}
textTransform="capitalize"
color={section.type === 'external-link' ? '#79F8FB' : 'white'}
>
{section.label}
</Text>
{section.type === 'external-link' && (
<ExternalLinkIcon color="#79F8FB" ml="10px" />
)}
</Link>
<SimpleGrid columns={2}>
{section.menuItems.map(({ title, icon, url }) => (
<Link
key={title}
display="flex"
alignItems="center"
href={url}
border="1px"
_odd={{ marginRight: '-1px' }}
marginBottom="-1px"
borderColor="purple.400"
bg="alphaBlack.50"
px={2}
py={1.5}
_hover={{
bg: 'alphaWhite.50',
}}
isExternal={/^https?:\/\//.test(url)}
>
<Avatar
name={title}
src={menuIcons[icon]}
p={0}
w={7}
h={7}
mr={1}
bg="linear-gradient(180deg, #170B23 0%, #350C58 100%)"
/>
<Text fontSize={20}>{title}</Text>
</Link>
))}
{section?.menuItems?.length &&
section.menuItems.map(({ title, icon, url }) => (
<Link
key={title}
display="flex"
alignItems="center"
href={url}
border="1px"
_odd={{ marginRight: '-1px' }}
marginBottom="-1px"
borderColor="purple.400"
bg="alphaBlack.50"
px={2}
py={1.5}
_hover={{
bg: 'alphaWhite.50',
}}
isExternal={/^https?:\/\//.test(url)}
>
<Avatar
name={title}
src={menuIcons[icon]}
p={0}
w={7}
h={7}
mr={1}
bg="linear-gradient(180deg, #170B23 0%, #350C58 100%)"
/>
<Text fontSize={20}>{title}</Text>
</Link>
))}
</SimpleGrid>
</Stack>
))}
Expand Down
Loading