microsite
Version:
<br /> <br />
54 lines (53 loc) • 1.66 kB
JavaScript
import { h } from "preact";
import { Head } from './head';
const statusCodes = {
400: "Bad Request",
404: "This page could not be found",
405: "Method Not Allowed",
500: "Internal Server Error",
};
const Error = (props = {}) => {
var _a, _b;
const { statusCode } = props;
const title = (_b = (_a = props.title) !== null && _a !== void 0 ? _a : statusCodes[statusCode]) !== null && _b !== void 0 ? _b : "An unexpected error has occurred";
return (h("div", { style: styles.error },
h(Head, null,
h("title", { "data-microsite-ignore": true },
statusCode,
": ",
title)),
h("div", null,
h("style", { dangerouslySetInnerHTML: { __html: "body { margin: 0 }" } }),
statusCode ? h("h1", { style: styles.h1 }, statusCode) : null,
h("h2", { style: styles.h2 },
title,
"."))));
};
const styles = {
error: {
color: '#000',
background: '#fff',
fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
height: '100vh',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
h1: {
display: 'block',
margin: 0,
fontSize: '40px',
fontWeight: 600,
},
h2: {
fontSize: '20px',
fontWeight: 'normal',
lineHeight: 'inherit',
margin: 0,
marginTop: '0.5em',
padding: 0,
},
};
export default Error;