Commit 12b0f109 authored by Max Alekseenko's avatar Max Alekseenko

add new layout for app fullscreen mode

parent f1c4d7a8
...@@ -6,6 +6,8 @@ import type { NextPageWithLayout } from 'nextjs/types'; ...@@ -6,6 +6,8 @@ import type { NextPageWithLayout } from 'nextjs/types';
import type { Props } from 'nextjs/getServerSideProps'; import type { Props } from 'nextjs/getServerSideProps';
import PageNextJs from 'nextjs/PageNextJs'; import PageNextJs from 'nextjs/PageNextJs';
import LayoutApp from 'ui/shared/layout/LayoutApp';
const MarketplaceApp = dynamic(() => import('ui/pages/MarketplaceApp'), { ssr: false }); const MarketplaceApp = dynamic(() => import('ui/pages/MarketplaceApp'), { ssr: false });
const Page: NextPageWithLayout<Props> = (props: Props) => { const Page: NextPageWithLayout<Props> = (props: Props) => {
...@@ -16,6 +18,14 @@ const Page: NextPageWithLayout<Props> = (props: Props) => { ...@@ -16,6 +18,14 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
); );
}; };
Page.getLayout = function getLayout(page: React.ReactElement) {
return (
<LayoutApp>
{ page }
</LayoutApp>
);
};
export default Page; export default Page;
export { marketplace as getServerSideProps } from 'nextjs/getServerSideProps'; export { marketplace as getServerSideProps } from 'nextjs/getServerSideProps';
...@@ -9,12 +9,10 @@ import { route } from 'nextjs-routes'; ...@@ -9,12 +9,10 @@ import { route } from 'nextjs-routes';
import config from 'configs/app'; import config from 'configs/app';
import type { ResourceError } from 'lib/api/resources'; import type { ResourceError } from 'lib/api/resources';
import { useAppContext } from 'lib/contexts/app';
import useApiFetch from 'lib/hooks/useFetch'; import useApiFetch from 'lib/hooks/useFetch';
import * as metadata from 'lib/metadata'; import * as metadata from 'lib/metadata';
import getQueryParamString from 'lib/router/getQueryParamString'; import getQueryParamString from 'lib/router/getQueryParamString';
import ContentLoader from 'ui/shared/ContentLoader'; import ContentLoader from 'ui/shared/ContentLoader';
import PageTitle from 'ui/shared/Page/PageTitle';
const feature = config.features.marketplace; const feature = config.features.marketplace;
const configUrl = feature.isEnabled ? feature.configUrl : ''; const configUrl = feature.isEnabled ? feature.configUrl : '';
...@@ -30,7 +28,6 @@ const MarketplaceApp = () => { ...@@ -30,7 +28,6 @@ const MarketplaceApp = () => {
const ref = useRef<HTMLIFrameElement>(null); const ref = useRef<HTMLIFrameElement>(null);
const apiFetch = useApiFetch(); const apiFetch = useApiFetch();
const appProps = useAppContext();
const router = useRouter(); const router = useRouter();
const id = getQueryParamString(router.query.id); const id = getQueryParamString(router.query.id);
...@@ -91,25 +88,10 @@ const MarketplaceApp = () => { ...@@ -91,25 +88,10 @@ const MarketplaceApp = () => {
throw new Error('Unable to load app', { cause: error }); throw new Error('Unable to load app', { cause: error });
} }
const backLink = React.useMemo(() => {
const hasGoBackLink = appProps.referrer.includes('/apps');
if (!hasGoBackLink) {
return;
}
return {
label: 'Back to marketplace',
url: appProps.referrer,
};
}, [ appProps.referrer ]);
return ( return (
<>
{ !isLoading && <PageTitle title={ data.title } backLink={ backLink }/> }
<Center <Center
h="100vh" h="100vh"
mx={{ base: -4, lg: -12 }} mx={{ base: -4, lg: -6 }}
> >
{ (isFrameLoading) && ( { (isFrameLoading) && (
<ContentLoader/> <ContentLoader/>
...@@ -130,7 +112,6 @@ const MarketplaceApp = () => { ...@@ -130,7 +112,6 @@ const MarketplaceApp = () => {
/> />
) } ) }
</Center> </Center>
</>
); );
}; };
......
import React from 'react';
import type { Props } from './types';
import AppErrorBoundary from 'ui/shared/AppError/AppErrorBoundary';
import Header from 'ui/snippets/header/Header';
import HeaderAlert from 'ui/snippets/header/HeaderAlert';
import * as Layout from './components';
const LayoutDefault = ({ children }: Props) => {
return (
<Layout.Container>
<Layout.MainArea>
<Layout.MainColumn
paddingTop={{ base: '138px', lg: 6 }}
paddingX={{ base: 4, lg: 6 }}
>
<HeaderAlert/>
<Header isAppPage/>
<AppErrorBoundary>
<Layout.Content pt={{ base: 0, lg: 6 }}>
{ children }
</Layout.Content>
</AppErrorBoundary>
</Layout.MainColumn>
</Layout.MainArea>
<Layout.Footer/>
</Layout.Container>
);
};
export default LayoutDefault;
import { Box } from '@chakra-ui/react'; import { Box, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
interface Props { interface Props {
className?: string;
children: React.ReactNode; children: React.ReactNode;
} }
const Content = ({ children }: Props) => { const Content = ({ children, className }: Props) => {
return ( return (
<Box pt={{ base: 0, lg: '52px' }} as="main"> <Box pt={{ base: 0, lg: '52px' }} as="main" className={ className }>
{ children } { children }
</Box> </Box>
); );
}; };
export default React.memo(Content); export default React.memo(chakra(Content));
...@@ -26,7 +26,7 @@ const Burger = () => { ...@@ -26,7 +26,7 @@ const Burger = () => {
return ( return (
<> <>
<Box padding={ 2 } onClick={ onOpen }> <Box padding={ 2 } onClick={ onOpen } cursor="pointer">
<Icon <Icon
as={ burgerIcon } as={ burgerIcon }
boxSize={ 6 } boxSize={ 6 }
......
...@@ -14,10 +14,11 @@ import Burger from './Burger'; ...@@ -14,10 +14,11 @@ import Burger from './Burger';
type Props = { type Props = {
isHomePage?: boolean; isHomePage?: boolean;
isAppPage?: boolean;
renderSearchBar?: () => React.ReactNode; renderSearchBar?: () => React.ReactNode;
} }
const Header = ({ isHomePage, renderSearchBar }: Props) => { const Header = ({ isHomePage, isAppPage, renderSearchBar }: Props) => {
const bgColor = useColorModeValue('white', 'black'); const bgColor = useColorModeValue('white', 'black');
const scrollDirection = useScrollDirection(); const scrollDirection = useScrollDirection();
...@@ -62,6 +63,12 @@ const Header = ({ isHomePage, renderSearchBar }: Props) => { ...@@ -62,6 +63,12 @@ const Header = ({ isHomePage, renderSearchBar }: Props) => {
justifyContent="center" justifyContent="center"
gap={ 12 } gap={ 12 }
> >
{ isAppPage && (
<Box display="flex" alignItems="center" gap={ 3 }>
<Burger/>
<NetworkLogo isCollapsed/>
</Box>
) }
<Box width="100%"> <Box width="100%">
{ searchBar } { 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