2020-10-07 09:41:58 -07:00
|
|
|
import * as React from 'react';
|
|
|
|
import { useRef } from 'react';
|
|
|
|
import { Flex, useColorMode } from '@chakra-ui/core';
|
|
|
|
import { useConfig, useHyperglassState } from 'app/context';
|
|
|
|
import { Debugger, Greeting, Footer, Header } from 'app/components';
|
2020-01-17 02:50:57 -07:00
|
|
|
|
2020-10-07 09:41:58 -07:00
|
|
|
const bg = { light: 'white', dark: 'black' };
|
|
|
|
const color = { light: 'black', dark: 'white' };
|
2020-01-20 00:37:04 -07:00
|
|
|
|
2020-09-28 11:54:00 -07:00
|
|
|
export const Layout = ({ children }) => {
|
2020-04-19 09:50:31 -07:00
|
|
|
const config = useConfig();
|
|
|
|
const { colorMode } = useColorMode();
|
2020-04-24 11:41:43 -07:00
|
|
|
const { greetingAck, setGreetingAck } = useHyperglassState();
|
2020-04-19 09:50:31 -07:00
|
|
|
const containerRef = useRef(null);
|
2020-04-16 00:26:23 -07:00
|
|
|
|
2020-04-19 09:50:31 -07:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Flex
|
|
|
|
w="100%"
|
|
|
|
ref={containerRef}
|
|
|
|
minHeight="100vh"
|
|
|
|
bg={bg[colorMode]}
|
|
|
|
flexDirection="column"
|
2020-10-07 09:41:58 -07:00
|
|
|
color={color[colorMode]}>
|
2020-04-19 09:50:31 -07:00
|
|
|
<Flex px={2} flex="0 1 auto" flexDirection="column">
|
2020-04-24 11:41:43 -07:00
|
|
|
<Header layoutRef={containerRef} />
|
2020-04-19 09:50:31 -07:00
|
|
|
</Flex>
|
|
|
|
<Flex
|
|
|
|
px={2}
|
|
|
|
py={0}
|
|
|
|
w="100%"
|
|
|
|
as="main"
|
|
|
|
flex="1 1 auto"
|
|
|
|
textAlign="center"
|
|
|
|
alignItems="center"
|
|
|
|
justifyContent="start"
|
2020-10-07 09:41:58 -07:00
|
|
|
flexDirection="column">
|
2020-04-24 11:41:43 -07:00
|
|
|
{children}
|
2020-04-19 09:50:31 -07:00
|
|
|
</Flex>
|
|
|
|
<Footer />
|
|
|
|
{config.developer_mode && <Debugger />}
|
|
|
|
</Flex>
|
|
|
|
{config.web.greeting.enable && !greetingAck && (
|
|
|
|
<Greeting
|
|
|
|
greetingConfig={config.web.greeting}
|
|
|
|
content={config.content.greeting}
|
|
|
|
onClickThrough={setGreetingAck}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
2020-01-17 02:50:57 -07:00
|
|
|
};
|