Commit f1529251 authored by tom's avatar tom

search bar transition and minor fixes

parent 8a367e1b
...@@ -34,6 +34,7 @@ const Burger = () => { ...@@ -34,6 +34,7 @@ const Burger = () => {
isOpen={ isOpen } isOpen={ isOpen }
placement="left" placement="left"
onClose={ onClose } onClose={ onClose }
autoFocus={ false }
> >
<DrawerOverlay/> <DrawerOverlay/>
<DrawerContent maxWidth="260px"> <DrawerContent maxWidth="260px">
......
import { HStack, VStack, Flex, useColorModeValue } from '@chakra-ui/react'; import { HStack, Box, Flex, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
...@@ -15,27 +15,26 @@ const Header = () => { ...@@ -15,27 +15,26 @@ const Header = () => {
if (isMobile) { if (isMobile) {
return ( return (
<VStack <Box bgColor={ bgColor }>
as="header"
position="fixed"
top={ 0 }
left={ 0 }
paddingX={ 4 }
paddingY={ 2 }
bgColor={ bgColor }
width="100%"
>
<Flex <Flex
as="header"
position="fixed"
top={ 0 }
left={ 0 }
paddingX={ 4 }
paddingY={ 2 }
bgColor={ bgColor }
width="100%" width="100%"
alignItems="center" alignItems="center"
justifyContent="space-between" justifyContent="space-between"
zIndex={ 10 }
> >
<Burger/> <Burger/>
<NetworkLogo/> <NetworkLogo/>
<ProfileMenu/> <ProfileMenu/>
</Flex> </Flex>
<SearchBar/> <SearchBar/>
</VStack> </Box>
); );
} }
......
...@@ -12,7 +12,7 @@ const NavigationMobile = () => { ...@@ -12,7 +12,7 @@ const NavigationMobile = () => {
return ( return (
<> <>
<Box as="nav" mt={ 8 }> <Box as="nav" mt={ 6 }>
<VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden"> <VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden">
{ mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isActive={ router.asPath === item.pathname }/>) } { mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isActive={ router.asPath === item.pathname }/>) }
</VStack> </VStack>
......
import { SearchIcon } from '@chakra-ui/icons'; import { SearchIcon } from '@chakra-ui/icons';
import { InputGroup, Input, InputLeftElement, useColorModeValue } from '@chakra-ui/react'; import { InputGroup, Input, InputLeftElement, useColorModeValue, chakra } from '@chakra-ui/react';
import throttle from 'lodash/throttle'; import throttle from 'lodash/throttle';
import React from 'react'; import React from 'react';
import type { ChangeEvent, FormEvent } from 'react'; import type { ChangeEvent, FormEvent } from 'react';
...@@ -20,6 +20,7 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => { ...@@ -20,6 +20,7 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => {
const searchIconColor = useColorModeValue('blackAlpha.600', 'whiteAlpha.600'); const searchIconColor = useColorModeValue('blackAlpha.600', 'whiteAlpha.600');
const inputBorderColor = useColorModeValue('blackAlpha.100', 'whiteAlpha.200'); const inputBorderColor = useColorModeValue('blackAlpha.100', 'whiteAlpha.200');
const bgColor = useColorModeValue('white', 'black');
const handleScroll = React.useCallback(() => { const handleScroll = React.useCallback(() => {
const currentScrollPosition = window.pageYOffset; const currentScrollPosition = window.pageYOffset;
...@@ -44,12 +45,21 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => { ...@@ -44,12 +45,21 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => {
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
if (!isVisible) {
return null;
}
return ( return (
<form noValidate onSubmit={ onSubmit }> <chakra.form
noValidate
onSubmit={ onSubmit }
paddingX={ 4 }
paddingTop={ 1 }
paddingBottom={ 2 }
position="fixed"
top="56px"
left="0"
bgColor={ bgColor }
transform={ isVisible ? 'translateY(0)' : 'translateY(-100%)' }
transitionProperty="transform"
transitionDuration="slow"
>
<InputGroup size="sm"> <InputGroup size="sm">
<InputLeftElement > <InputLeftElement >
<SearchIcon w={ 4 } h={ 4 } color={ searchIconColor }/> <SearchIcon w={ 4 } h={ 4 } color={ searchIconColor }/>
...@@ -62,7 +72,7 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => { ...@@ -62,7 +72,7 @@ const SearchBarMobile = ({ onChange, onSubmit }: Props) => {
borderColor={ inputBorderColor } borderColor={ inputBorderColor }
/> />
</InputGroup> </InputGroup>
</form> </chakra.form>
); );
}; };
......
...@@ -33,13 +33,14 @@ const Page = ({ children }: Props) => { ...@@ -33,13 +33,14 @@ const Page = ({ children }: Props) => {
alignItems="stretch" alignItems="stretch"
> >
{ !isMobile && <NavigationDesktop/> } { !isMobile && <NavigationDesktop/> }
<VStack width="100%" paddingX={ isMobile ? 4 : 8 } paddingTop={ isMobile ? '104px' : 9 } paddingBottom={ 10 }> <VStack width="100%" paddingX={ isMobile ? 4 : 8 } paddingTop={ isMobile ? 0 : 9 } paddingBottom={ 10 } spacing={ 0 }>
<Header/> <Header/>
<Box <Box
as="main" as="main"
borderRadius="base" borderRadius="base"
w="100%" w="100%"
overflow="hidden" overflow="hidden"
paddingTop={ isMobile ? '138px' : '52px' }
> >
{ children } { children }
</Box> </Box>
......
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