Commit cb844b8a authored by Max Alekseenko's avatar Max Alekseenko

fix app layout for mobiles

parent b77b92b4
import { Global, css } from '@emotion/react';
import React from 'react'; import React from 'react';
import type { Props } from './types'; import type { Props } from './types';
...@@ -9,24 +10,43 @@ import * as Layout from './components'; ...@@ -9,24 +10,43 @@ import * as Layout from './components';
const LayoutDefault = ({ children }: Props) => { const LayoutDefault = ({ children }: Props) => {
return ( return (
<Layout.Container overflowY="hidden" height="100vh"> <>
<Layout.TopRow/> <Global
<HeaderMobile/> styles={ css`
<Layout.MainArea> html {
<Layout.MainColumn height: -webkit-fill-available;
paddingTop={{ base: 16, lg: 0 }} }
paddingBottom={ 0 } body {
paddingX={{ base: 4, lg: 6 }} height: 100vh;
height={{ base: 'calc(100vh - 92px)', sm: 'auto' }} // 92px = Layout.TopRow + HeaderMobile height: -webkit-fill-available;
> display: flex;
<AppErrorBoundary> flex-direction: column;
<Layout.Content pt={{ base: 0, lg: 2 }} flexGrow={ 1 }> }
{ children } #__next {
</Layout.Content> flex: 1;
</AppErrorBoundary> display: flex;
</Layout.MainColumn> flex-direction: column;
</Layout.MainArea> }
</Layout.Container> ` }
/>
<Layout.Container overflowY="hidden" flex={ 1 } display="flex" flexDir="column">
<Layout.TopRow/>
<HeaderMobile hideSearchBar/>
<Layout.MainArea minH="auto" flex={ 1 }>
<Layout.MainColumn
paddingTop={{ base: 0, lg: 0 }}
paddingBottom={ 0 }
paddingX={{ base: 4, lg: 6 }}
>
<AppErrorBoundary>
<Layout.Content pt={{ base: 0, lg: 2 }} flexGrow={ 1 }>
{ children }
</Layout.Content>
</AppErrorBoundary>
</Layout.MainColumn>
</Layout.MainArea>
</Layout.Container>
</>
); );
}; };
......
...@@ -12,7 +12,7 @@ const LayoutHome = ({ children }: Props) => { ...@@ -12,7 +12,7 @@ const LayoutHome = ({ children }: Props) => {
return ( return (
<Layout.Container> <Layout.Container>
<Layout.TopRow/> <Layout.TopRow/>
<HeaderMobile isHomePage/> <HeaderMobile hideSearchBar/>
<Layout.MainArea> <Layout.MainArea>
<Layout.SideBar/> <Layout.SideBar/>
<Layout.MainColumn <Layout.MainColumn
......
import { Flex } from '@chakra-ui/react'; import { Flex, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
interface Props { interface Props {
children: React.ReactNode; children: React.ReactNode;
className?: string;
} }
const MainArea = ({ children }: Props) => { const MainArea = ({ children, className }: Props) => {
return ( return (
<Flex w="100%" minH="calc(100vh - 36px)" alignItems="stretch"> <Flex className={ className } w="100%" minH="calc(100vh - 36px)" alignItems="stretch">
{ children } { children }
</Flex> </Flex>
); );
}; };
export default React.memo(MainArea); export default React.memo(chakra(MainArea));
...@@ -16,11 +16,11 @@ const LOGO_IMAGE_PROPS = { ...@@ -16,11 +16,11 @@ const LOGO_IMAGE_PROPS = {
}; };
type Props = { type Props = {
isHomePage?: boolean; hideSearchBar?: boolean;
renderSearchBar?: () => React.ReactNode; renderSearchBar?: () => React.ReactNode;
} }
const HeaderMobile = ({ isHomePage, renderSearchBar }: Props) => { const HeaderMobile = ({ hideSearchBar, renderSearchBar }: Props) => {
const bgColor = useColorModeValue('white', 'black'); const bgColor = useColorModeValue('white', 'black');
const scrollDirection = useScrollDirection(); const scrollDirection = useScrollDirection();
const { ref, inView } = useInView({ threshold: 1 }); const { ref, inView } = useInView({ threshold: 1 });
...@@ -57,7 +57,7 @@ const HeaderMobile = ({ isHomePage, renderSearchBar }: Props) => { ...@@ -57,7 +57,7 @@ const HeaderMobile = ({ isHomePage, renderSearchBar }: Props) => {
{ config.features.blockchainInteraction.isEnabled && <WalletMenuMobile/> } { config.features.blockchainInteraction.isEnabled && <WalletMenuMobile/> }
</Flex> </Flex>
</Flex> </Flex>
{ !isHomePage && searchBar } { !hideSearchBar && searchBar }
</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