Commit 8a367e1b authored by tom's avatar tom

mobile burger fixes

parent d6aa6995
import type { drawerAnatomy as parts } from '@chakra-ui/anatomy';
import type { SystemStyleFunction, PartsStyleFunction, SystemStyleObject } from '@chakra-ui/theme-tools';
import { mode } from '@chakra-ui/theme-tools';
const baseStyleOverlay: SystemStyleObject = {
bg: 'blackAlpha.800',
zIndex: 'overlay',
};
const baseStyleDialog: SystemStyleFunction = (props) => {
const { isFullHeight } = props;
return {
...(isFullHeight && { height: '100vh' }),
zIndex: 'modal',
maxH: '100vh',
bg: mode('white', 'gray.900')(props),
color: 'inherit',
boxShadow: mode('lg', 'dark-lg')(props),
};
};
const baseStyle: PartsStyleFunction<typeof parts> = (props) => ({
overlay: baseStyleOverlay,
dialog: baseStyleDialog(props),
});
const Drawer = {
baseStyle,
};
export default Drawer;
import Button from './Button'; import Button from './Button';
import Checkbox from './Checkbox'; import Checkbox from './Checkbox';
import Drawer from './Drawer';
import Form from './Form'; import Form from './Form';
import Heading from './Heading'; import Heading from './Heading';
import Input from './Input'; import Input from './Input';
...@@ -18,6 +19,7 @@ import Tooltip from './Tooltip'; ...@@ -18,6 +19,7 @@ import Tooltip from './Tooltip';
const components = { const components = {
Button, Button,
Checkbox, Checkbox,
Drawer,
Heading, Heading,
Input, Input,
Form, Form,
......
...@@ -16,6 +16,10 @@ const Burger = () => { ...@@ -16,6 +16,10 @@ const Burger = () => {
setNetworkMenuVisibility((flag) => !flag); setNetworkMenuVisibility((flag) => !flag);
}, []); }, []);
const handleNetworkLogoClick = React.useCallback(() => {
setNetworkMenuVisibility(false);
}, []);
return ( return (
<> <>
<Box padding={ 2 } onClick={ onOpen }> <Box padding={ 2 } onClick={ onOpen }>
...@@ -31,11 +35,11 @@ const Burger = () => { ...@@ -31,11 +35,11 @@ const Burger = () => {
placement="left" placement="left"
onClose={ onClose } onClose={ onClose }
> >
<DrawerOverlay bgColor="blackAlpha.800"/> <DrawerOverlay/>
<DrawerContent maxWidth="260px"> <DrawerContent maxWidth="260px">
<DrawerBody p={ 6 }> <DrawerBody p={ 6 }>
<Flex alignItems="center" justifyContent="space-between"> <Flex alignItems="center" justifyContent="space-between">
<NetworkLogo/> <NetworkLogo onClick={ handleNetworkLogoClick }/>
<NetworkMenuButton <NetworkMenuButton
isCollapsed isCollapsed
isMobile isMobile
......
...@@ -52,7 +52,7 @@ const NavLink = ({ text, pathname, icon, isCollapsed, isActive }: Props) => { ...@@ -52,7 +52,7 @@ const NavLink = ({ text, pathname, icon, isCollapsed, isActive }: Props) => {
> >
<HStack spacing={ 3 }> <HStack spacing={ 3 }>
<Icon as={ icon } boxSize="30px"/> <Icon as={ icon } boxSize="30px"/>
{ !isCollapsed && <Text variant="inherit">{ text }</Text> } { !isCollapsed && <Text variant="inherit" fontSize="sm" lineHeight="20px">{ text }</Text> }
</HStack> </HStack>
</Tooltip> </Tooltip>
</Link> </Link>
......
...@@ -6,9 +6,10 @@ import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps'; ...@@ -6,9 +6,10 @@ import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
interface Props { interface Props {
isCollapsed?: boolean; isCollapsed?: boolean;
onClick?: () => void;
} }
const NetworkLogo = ({ isCollapsed }: Props) => { const NetworkLogo = ({ isCollapsed, onClick }: Props) => {
const logoColor = useColorModeValue('blue.600', 'white'); const logoColor = useColorModeValue('blue.600', 'white');
return ( return (
...@@ -16,6 +17,7 @@ const NetworkLogo = ({ isCollapsed }: Props) => { ...@@ -16,6 +17,7 @@ const NetworkLogo = ({ isCollapsed }: Props) => {
width={ isCollapsed ? '0' : '113px' } width={ isCollapsed ? '0' : '113px' }
display="inline-flex" display="inline-flex"
overflow="hidden" overflow="hidden"
onClick={ onClick }
{ ...getDefaultTransitionProps({ transitionProperty: 'width' }) } { ...getDefaultTransitionProps({ transitionProperty: 'width' }) }
> >
<Icon <Icon
......
...@@ -13,6 +13,8 @@ interface Props { ...@@ -13,6 +13,8 @@ interface Props {
const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props, ref: React.ForwardedRef<HTMLButtonElement>) => { const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props, ref: React.ForwardedRef<HTMLButtonElement>) => {
const defaultIconColor = useColorModeValue('gray.600', 'gray.400'); const defaultIconColor = useColorModeValue('gray.600', 'gray.400');
const bgColorMobile = useColorModeValue('blue.50', 'gray.800');
const iconColorMobile = useColorModeValue('blue.700', 'blue.50');
return ( return (
<Button <Button
...@@ -23,7 +25,7 @@ const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props, ...@@ -23,7 +25,7 @@ const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props,
ref={ ref } ref={ ref }
h="36px" h="36px"
borderRadius="base" borderRadius="base"
backgroundColor={ isMobile && isActive ? 'blue.50' : 'none' } backgroundColor={ isMobile && isActive ? bgColorMobile : 'none' }
onClick={ onClick } onClick={ onClick }
> >
<Icon <Icon
...@@ -31,7 +33,7 @@ const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props, ...@@ -31,7 +33,7 @@ const NetworkMenuButton = ({ isCollapsed, isMobile, isActive, onClick }: Props,
width="36px" width="36px"
height="36px" height="36px"
padding="10px" padding="10px"
color={ isMobile && isActive ? 'blue.700' : defaultIconColor } color={ isMobile && isActive ? iconColorMobile : defaultIconColor }
_hover={{ color: isMobile ? undefined : 'blue.400' }} _hover={{ color: isMobile ? undefined : 'blue.400' }}
marginLeft={ isCollapsed ? '0px' : '7px' } marginLeft={ isCollapsed ? '0px' : '7px' }
cursor="pointer" cursor="pointer"
......
...@@ -35,6 +35,7 @@ const NetworkMenuContentMobile = () => { ...@@ -35,6 +35,7 @@ const NetworkMenuContentMobile = () => {
{ ...network } { ...network }
isActive={ network.name === selectedNetwork?.name } isActive={ network.name === selectedNetwork?.name }
routeName={ routeName } routeName={ routeName }
isMobile
/> />
)) ))
} }
......
...@@ -12,10 +12,11 @@ import useColors from './useColors'; ...@@ -12,10 +12,11 @@ import useColors from './useColors';
interface Props extends Network { interface Props extends Network {
isActive: boolean; isActive: boolean;
isMobile?: boolean;
routeName: string; routeName: string;
} }
const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAccountSupported }: Props) => { const NetworkMenuLink = ({ name, type, subType, icon, isActive, isMobile, routeName, isAccountSupported }: Props) => {
const isAccount = isAccountRoute(routeName); const isAccount = isAccountRoute(routeName);
const localPath = (() => { const localPath = (() => {
if (isAccount && isAccountSupported) { if (isAccount && isAccountSupported) {
...@@ -51,8 +52,8 @@ const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAcc ...@@ -51,8 +52,8 @@ const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAcc
<NextLink href={ href } passHref> <NextLink href={ href } passHref>
<Flex <Flex
as="a" as="a"
px={ 4 } px={ isMobile ? 3 : 4 }
py={ 3 } py={ 2 }
alignItems="center" alignItems="center"
cursor="pointer" cursor="pointer"
pointerEvents={ isActive ? 'none' : 'initial' } pointerEvents={ isActive ? 'none' : 'initial' }
...@@ -66,6 +67,8 @@ const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAcc ...@@ -66,6 +67,8 @@ const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAcc
marginLeft={ 3 } marginLeft={ 3 }
fontWeight="500" fontWeight="500"
color="inherit" color="inherit"
fontSize={ isMobile ? 'sm' : 'md' }
lineHeight={ isMobile ? '20px' : '24px' }
> >
{ name } { name }
</Text> </Text>
......
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