Layout extraction refactoring
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { FC } from "react";
|
||||
import Head from "next/head";
|
||||
import { Stack, VStack, HStack, Heading, Text, Icon, useColorModeValue } from "@chakra-ui/react";
|
||||
import { Stack, HStack, Heading, Text, Icon, useColorModeValue } from "@chakra-ui/react";
|
||||
import { FaSadTear } from "react-icons/fa";
|
||||
import Header from "./Header";
|
||||
import Footer from "./Footer";
|
||||
import Layout from "./Layout";
|
||||
|
||||
const statusTexts: {
|
||||
[key: string]: string
|
||||
@@ -20,38 +18,26 @@ type Props = {
|
||||
};
|
||||
|
||||
const CustomError: FC<Props> = ({ statusCode }) => (
|
||||
<>
|
||||
<Head>
|
||||
<title>
|
||||
{statusCode} - {statusTexts?.[statusCode] ?? statusTexts.fallback}
|
||||
</title>
|
||||
<link rel="icon" href="/favicon.svg" />
|
||||
</Head>
|
||||
|
||||
<VStack h="100vh">
|
||||
<Header/>
|
||||
<Stack
|
||||
as="main"
|
||||
flexGrow={1}
|
||||
color={useColorModeValue("lingva.900", "lingva.100")}
|
||||
direction={["column", null, "row"]}
|
||||
justify="center"
|
||||
align="center"
|
||||
spacing={4}
|
||||
>
|
||||
<HStack align="center" spacing={5}>
|
||||
<Heading as="h1" size="3xl">
|
||||
{statusCode}
|
||||
</Heading>
|
||||
<Icon as={FaSadTear} boxSize={10} />
|
||||
</HStack>
|
||||
<Text as="h2" fontSize="xl">
|
||||
{statusTexts?.[statusCode] ?? statusTexts.fallback}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Footer/>
|
||||
</VStack>
|
||||
</>
|
||||
<Layout customTitle={`${statusCode} - ${statusTexts?.[statusCode] ?? statusTexts.fallback}`}>
|
||||
<Stack
|
||||
color={useColorModeValue("lingva.900", "lingva.100")}
|
||||
direction={["column", null, "row"]}
|
||||
justify="center"
|
||||
align="center"
|
||||
spacing={4}
|
||||
w="full"
|
||||
>
|
||||
<HStack align="center" spacing={5}>
|
||||
<Heading as="h1" size="3xl">
|
||||
{statusCode}
|
||||
</Heading>
|
||||
<Icon as={FaSadTear} boxSize={10} />
|
||||
</HStack>
|
||||
<Text as="h2" fontSize="xl">
|
||||
{statusTexts?.[statusCode] ?? statusTexts.fallback}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Layout>
|
||||
);
|
||||
|
||||
export default CustomError;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { FC, ChangeEvent } from "react";
|
||||
import { Select } from "@chakra-ui/react";
|
||||
|
||||
|
||||
type Props = {
|
||||
value: string,
|
||||
onChange: (e: ChangeEvent<any>) => void,
|
||||
|
||||
52
components/Layout.tsx
Normal file
52
components/Layout.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { FC } from "react";
|
||||
import { Flex, VStack, Button, Link } from "@chakra-ui/react";
|
||||
import Head from "next/head";
|
||||
import Header from "./Header";
|
||||
import Footer from "./Footer";
|
||||
|
||||
type Props = {
|
||||
customTitle?: string
|
||||
[key: string]: any
|
||||
};
|
||||
|
||||
const title = "Lingva Translate";
|
||||
|
||||
const Layout: FC<Props> = ({ customTitle, children }) => (
|
||||
<>
|
||||
<Head>
|
||||
<title>
|
||||
{customTitle ?? title}
|
||||
</title>
|
||||
<link rel="icon" href="/favicon.svg" />
|
||||
</Head>
|
||||
|
||||
<Button
|
||||
as={Link}
|
||||
href="#main"
|
||||
userSelect="none"
|
||||
position="absolute"
|
||||
top="-100px"
|
||||
left="0"
|
||||
_focus={{
|
||||
top: "0"
|
||||
}}
|
||||
>
|
||||
Skip to content
|
||||
</Button>
|
||||
|
||||
<VStack minH="100vh" spacing={8}>
|
||||
<Header />
|
||||
<Flex
|
||||
as="main"
|
||||
id="main"
|
||||
flexGrow={1}
|
||||
w="full"
|
||||
>
|
||||
{children}
|
||||
</Flex>
|
||||
<Footer />
|
||||
</VStack>
|
||||
</>
|
||||
);
|
||||
|
||||
export default Layout;
|
||||
@@ -1,5 +1,4 @@
|
||||
export { default as CustomError } from "./CustomError";
|
||||
export { default as Header } from "./Header";
|
||||
export { default as Footer } from "./Footer";
|
||||
export { default as Layout } from "./Layout";
|
||||
export { default as LangSelect } from "./LangSelect";
|
||||
export { default as TranslationArea } from "./TranslationArea";
|
||||
|
||||
Reference in New Issue
Block a user