Custom error page

This commit is contained in:
David
2021-03-16 23:58:12 +01:00
parent 75757ae5a7
commit 0646b17c9b
7 changed files with 81 additions and 7 deletions

View File

@@ -0,0 +1,56 @@
import { FC } from "react";
import Head from "next/head";
import { Stack, VStack, HStack, Heading, Text, Icon, useColorModeValue } from "@chakra-ui/react";
import { FaSadTear } from "react-icons/fa";
import Header from "./Header";
import Footer from "./Footer";
const statusTexts: {
[key: string]: string
} = {
400: "Bad Request",
404: "This page could not be found",
405: "Method Not Allowed",
500: "Internal Server Error",
fallback: "An unexpected error has occurred"
};
type Props = {
statusCode: number
};
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
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>
</>
);
export default CustomError;

View File

@@ -11,6 +11,7 @@ const Footer: FC<Props> = (props) => (
p={3}
fontSize={["sm", null, "md"]}
bgColor={useColorModeValue("lingva.100", "lingva.900")}
color={useColorModeValue("lingva.800", "lingva.200")}
{...props}
>
<Text as="span">&#169; 2021 TheDavidDelta</Text>

View File

@@ -1,5 +1,5 @@
import { FC } from "react";
import { Flex, HStack, useColorModeValue, IconButton, Link } from "@chakra-ui/react";
import { Flex, HStack, IconButton, Link, useColorModeValue } from "@chakra-ui/react";
import { FaGithub } from "react-icons/fa";
import Image from "next/image";
import ColorModeToggler from "./ColorModeToggler";

View File

@@ -1,3 +1,4 @@
export { default as CustomError } from "./CustomError";
export { default as Header } from "./Header";
export { default as Footer } from "./Footer";
export { default as LangSelect } from "./LangSelect";