Commit 3dd86083 authored by tom's avatar tom

fix user profile menu

parent b970f662
...@@ -20,16 +20,17 @@ type Props = { ...@@ -20,16 +20,17 @@ type Props = {
px?: string | number; px?: string | number;
className?: string; className?: string;
onClick?: () => void; onClick?: () => void;
disableActiveState?: boolean;
} }
const NavLink = ({ item, isCollapsed, px, className, onClick }: Props) => { const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState }: Props) => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const colors = useColors(); const colors = useColors();
const isExpanded = isCollapsed === false; const isExpanded = isCollapsed === false;
const isInternalLink = isInternalItem(item); const isInternalLink = isInternalItem(item);
const styleProps = useNavLinkStyleProps({ isCollapsed, isExpanded, isActive: isInternalLink && item.isActive }); const styleProps = useNavLinkStyleProps({ isCollapsed, isExpanded, isActive: isInternalLink && item.isActive && !disableActiveState });
const isXLScreen = useBreakpointValue({ base: false, xl: true }); const isXLScreen = useBreakpointValue({ base: false, xl: true });
const href = isInternalLink ? route(item.nextRoute) : item.url; const href = isInternalLink ? route(item.nextRoute) : item.url;
......
import { Box, Button, Text, VStack, useColorModeValue } from '@chakra-ui/react'; import { Box, Button, VStack, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { UserInfo } from 'types/api/account'; import type { UserInfo } from 'types/api/account';
...@@ -18,7 +18,6 @@ type Props = { ...@@ -18,7 +18,6 @@ type Props = {
const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => { const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => {
const { accountNavItems, profileItem } = useNavItems(); const { accountNavItems, profileItem } = useNavItems();
const primaryTextColor = useColorModeValue('blackAlpha.800', 'whiteAlpha.800');
const handleSingOutClick = React.useCallback(() => { const handleSingOutClick = React.useCallback(() => {
mixpanel.logEvent( mixpanel.logEvent(
...@@ -32,37 +31,28 @@ const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => { ...@@ -32,37 +31,28 @@ const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => {
return null; return null;
} }
const userName = data?.email || data?.nickname || data?.name;
return ( return (
<Box> <Box>
{ (data?.name || data?.nickname) && ( { userName && (
<Text <Box
fontSize="sm" fontSize="sm"
fontWeight={ 500 } fontWeight={ 500 }
color={ primaryTextColor }
{ ...getDefaultTransitionProps() }
>
Signed in as { data.name || data.nickname }
</Text>
) }
{ data?.email && (
<Text
fontSize="sm"
mb={ 1 } mb={ 1 }
fontWeight={ 500 }
color="gray.500"
{ ...getDefaultTransitionProps() }
> >
{ data.email } <span>Signed in as </span>
</Text> <chakra.span color="text_secondary">{ userName }</chakra.span>
</Box>
) } ) }
<NavLink item={ profileItem } isActive={ undefined } px="0px" isCollapsed={ false } onClick={ onNavLinkClick }/> <NavLink item={ profileItem } disableActiveState={ true } px="0px" isCollapsed={ false } onClick={ onNavLinkClick }/>
<Box as="nav" mt={ 2 } pt={ 2 } borderTopColor="divider" borderTopWidth="1px" { ...getDefaultTransitionProps() }> <Box as="nav" mt={ 2 } pt={ 2 } borderTopColor="divider" borderTopWidth="1px" { ...getDefaultTransitionProps() }>
<VStack as="ul" spacing="0" alignItems="flex-start" overflow="hidden"> <VStack as="ul" spacing="0" alignItems="flex-start" overflow="hidden">
{ accountNavItems.map((item) => ( { accountNavItems.map((item) => (
<NavLink <NavLink
key={ item.text } key={ item.text }
item={ item } item={ item }
isActive={ undefined } disableActiveState={ true }
isCollapsed={ false } isCollapsed={ false }
px="0px" px="0px"
onClick={ onNavLinkClick } onClick={ onNavLinkClick }
......
...@@ -97,7 +97,7 @@ const ProfileMenuDesktop = ({ isHomePage, className, fallbackIconSize }: Props) ...@@ -97,7 +97,7 @@ const ProfileMenuDesktop = ({ isHomePage, className, fallbackIconSize }: Props)
</Box> </Box>
</Tooltip> </Tooltip>
{ hasMenu && ( { hasMenu && (
<PopoverContent w="212px"> <PopoverContent maxW="400px" minW="220px" w="min-content">
<PopoverBody padding="24px 16px 16px 16px"> <PopoverBody padding="24px 16px 16px 16px">
<ProfileMenuContent data={ data }/> <ProfileMenuContent data={ data }/>
</PopoverBody> </PopoverBody>
......
...@@ -66,7 +66,7 @@ const ProfileMenuMobile = () => { ...@@ -66,7 +66,7 @@ const ProfileMenuMobile = () => {
autoFocus={ false } autoFocus={ false }
> >
<DrawerOverlay/> <DrawerOverlay/>
<DrawerContent maxWidth="260px"> <DrawerContent maxWidth="300px">
<DrawerBody p={ 6 }> <DrawerBody p={ 6 }>
<ProfileMenuContent data={ data } onNavLinkClick={ onClose }/> <ProfileMenuContent data={ data } onNavLinkClick={ onClose }/>
</DrawerBody> </DrawerBody>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment