Commit 3b9e452e authored by tom's avatar tom

smooth collapsing of left bar

parent ee17ad79
export default function getDefaultTransitionProps() { export default function getDefaultTransitionProps(props?: {transitionProperty: string}) {
return { return {
transitionProperty: 'background-color, color, border-color', transitionProperty: `background-color, color, border-color${ props?.transitionProperty ? ', ' + props.transitionProperty : '' }`,
transitionDuration: 'normal', transitionDuration: 'normal',
transitionTimingFunction: 'ease', transitionTimingFunction: 'ease',
}; };
......
...@@ -25,13 +25,13 @@ const NavFooter = ({ isCollapsed }: Props) => { ...@@ -25,13 +25,13 @@ const NavFooter = ({ isCollapsed }: Props) => {
spacing={ 8 } spacing={ 8 }
borderTop="1px solid" borderTop="1px solid"
borderColor={ useColorModeValue('blackAlpha.200', 'whiteAlpha.200') } borderColor={ useColorModeValue('blackAlpha.200', 'whiteAlpha.200') }
width={ isCollapsed ? '20px' : '180px' }
paddingTop={ 8 } paddingTop={ 8 }
marginTop={ 20 } marginTop={ 20 }
// w="100%" alignItems="flex-start"
alignItems="baseline"
color="gray.500" color="gray.500"
fontSize="xs" fontSize="xs"
{ ...getDefaultTransitionProps() } { ...getDefaultTransitionProps({ transitionProperty: 'width' }) }
> >
<Stack direction={ isCollapsed ? 'column' : 'row' }> <Stack direction={ isCollapsed ? 'column' : 'row' }>
{ SOCIAL_LINKS.map(sl => { { SOCIAL_LINKS.map(sl => {
......
...@@ -3,6 +3,8 @@ import NextLink from 'next/link'; ...@@ -3,6 +3,8 @@ import NextLink from 'next/link';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
import useColors from './useColors'; import useColors from './useColors';
interface Props { interface Props {
...@@ -30,6 +32,8 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => { ...@@ -30,6 +32,8 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => {
bgColor={ isActive ? colors.bg.active : colors.bg.default } bgColor={ isActive ? colors.bg.active : colors.bg.default }
_hover={{ color: isActive ? colors.text.active : colors.text.hover }} _hover={{ color: isActive ? colors.text.active : colors.text.hover }}
borderRadius="base" borderRadius="base"
whiteSpace="nowrap"
{ ...getDefaultTransitionProps({ transitionProperty: 'width, padding' }) }
> >
<HStack spacing={ 3 }> <HStack spacing={ 3 }>
<Icon as={ icon } boxSize="30px"/> <Icon as={ icon } boxSize="30px"/>
......
import { ChevronLeftIcon } from '@chakra-ui/icons'; import { ChevronLeftIcon } from '@chakra-ui/icons';
import { Flex, HStack, Icon, Box, VStack, useColorModeValue } from '@chakra-ui/react'; import { Flex, Icon, Box, VStack, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import abiIcon from 'icons/ABI.svg'; import abiIcon from 'icons/ABI.svg';
...@@ -54,17 +54,24 @@ const Navigation = () => { ...@@ -54,17 +54,24 @@ const Navigation = () => {
px={ isCollapsed ? 4 : 6 } px={ isCollapsed ? 4 : 6 }
py={ 12 } py={ 12 }
width={ isCollapsed ? '92px' : '229px' } width={ isCollapsed ? '92px' : '229px' }
{ ...getDefaultTransitionProps() } { ...getDefaultTransitionProps({ transitionProperty: 'width, padding' }) }
> >
<HStack <Box
as="header" as="header"
justifyContent={ isCollapsed ? 'center' : 'space-between' } display="flex"
justifyContent="center"
alignItems="center" alignItems="center"
flexDirection="row"
w="100%" w="100%"
px={ 3 } px={ 3 }
h={ 10 } h={ 10 }
> >
{ !isCollapsed && ( <Box
width={ isCollapsed ? '0' : '113px' }
display="inline-flex"
overflow="hidden"
{ ...getDefaultTransitionProps({ transitionProperty: 'width' }) }
>
<Icon <Icon
as={ logoIcon } as={ logoIcon }
width="113px" width="113px"
...@@ -72,22 +79,23 @@ const Navigation = () => { ...@@ -72,22 +79,23 @@ const Navigation = () => {
color={ logoColor } color={ logoColor }
{ ...getDefaultTransitionProps() } { ...getDefaultTransitionProps() }
/> />
) } </Box>
<Icon <Icon
as={ networksIcon } as={ networksIcon }
width="16px" width="16px"
height="16px" height="16px"
color={ useColorModeValue('gray.500', 'white') } color={ useColorModeValue('gray.500', 'white') }
{ ...getDefaultTransitionProps() } marginLeft={ isCollapsed ? '0px' : '27px' }
{ ...getDefaultTransitionProps({ transitionProperty: 'margin' }) }
/> />
</HStack> </Box>
<Box as="nav" mt={ 14 }> <Box as="nav" mt={ 14 }>
<VStack as="ul" spacing="2"> <VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden">
{ mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) } { mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) }
</VStack> </VStack>
</Box> </Box>
<Box as="nav" mt={ 12 }> <Box as="nav" mt={ 12 }>
<VStack as="ul" spacing="2"> <VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden">
{ accountNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) } { accountNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) }
</VStack> </VStack>
</Box> </Box>
...@@ -101,6 +109,7 @@ const Navigation = () => { ...@@ -101,6 +109,7 @@ const Navigation = () => {
borderColor={ useColorModeValue('blackAlpha.200', 'whiteAlpha.200') } borderColor={ useColorModeValue('blackAlpha.200', 'whiteAlpha.200') }
borderRadius="base" borderRadius="base"
transform={ isCollapsed ? 'rotate(180deg)' : 'rotate(0)' } transform={ isCollapsed ? 'rotate(180deg)' : 'rotate(0)' }
{ ...getDefaultTransitionProps({ transitionProperty: 'transform' }) }
transformOrigin="center" transformOrigin="center"
position="absolute" position="absolute"
top="104px" top="104px"
......
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