1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

63 lines
1.7 KiB
JavaScript
Raw Normal View History

import * as React from "react";
import { useRef } from "react";
import { Flex, useColorMode } from "@chakra-ui/core";
2020-01-17 02:50:57 -07:00
import Header from "~/components/Header";
import Footer from "~/components/Footer";
2020-04-16 00:26:23 -07:00
import Greeting from "~/components/Greeting";
2020-01-17 02:50:57 -07:00
import Meta from "~/components/Meta";
import useConfig, { useHyperglassState } from "~/components/HyperglassProvider";
2020-01-20 00:37:04 -07:00
import Debugger from "~/components/Debugger";
2020-01-17 02:50:57 -07:00
2020-01-20 00:37:04 -07:00
const bg = { light: "white", dark: "black" };
const color = { light: "black", dark: "white" };
const Layout = ({ children }) => {
2020-04-19 09:50:31 -07:00
const config = useConfig();
const { colorMode } = useColorMode();
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 (
<>
<Meta />
<Flex
w="100%"
ref={containerRef}
minHeight="100vh"
bg={bg[colorMode]}
flexDirection="column"
color={color[colorMode]}
>
<Flex px={2} flex="0 1 auto" flexDirection="column">
<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"
flexDirection="column"
>
{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
};
2020-01-20 00:37:04 -07:00
Layout.displayName = "HyperglassLayout";
export default Layout;