Skip to content

Commit 917b1fd

Browse files
authored
Added styles for error pages (#18)
2 parents 27eda42 + 4fc82e6 commit 917b1fd

File tree

6 files changed

+116
-1
lines changed

6 files changed

+116
-1
lines changed

src/app.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import LandingPage from "./page/landing-page/landing-page.jsx";
33
import BasicPage from "./page/basic-page/basic-page.jsx";
4+
import ProblemPages from "./page/system/problem-pages.jsx";
45

56
/**
67
* PageTypes maps server resource types to the component that should render them.
@@ -20,7 +21,18 @@ const PageTypes = {
2021
*/
2122
const App = ({ resource, problem }) => {
2223
if (problem) {
23-
return (<div><h1>Error</h1><p>An unexpected problem occurred.</p></div>);
24+
const statusCode = problem.response.status;
25+
const phrases = {
26+
403: 'Sign in or get out!',
27+
404: "Oops, this is not the page you're looking for.",
28+
};
29+
const text = phrases?.[statusCode] || 'Something went terribly, terribly wrong.';
30+
return (
31+
<ProblemPages
32+
status={statusCode}
33+
text={text}
34+
/>
35+
);
2436
}
2537
// Extract the type of the current resource.
2638
const { type } = resource;

src/page/system/problem-pages.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
import './problem-pages.pcss';
3+
4+
const ProblemPages = ({status, text}) => {
5+
return (
6+
<div className={"main-content error-pages page-" + status }>
7+
<div className="content-wrapper">
8+
<div className="icon"></div>
9+
<h2 className={'page-title'}>{status}</h2>
10+
<p className={'text'}>{text}</p>
11+
</div>
12+
</div>
13+
);
14+
};
15+
16+
export default ProblemPages;

src/page/system/problem-pages.pcss

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.main-content.error-pages {
2+
height: 100vh;
3+
position: relative;
4+
overflow: hidden;
5+
6+
&::after {
7+
content: '';
8+
position: absolute;
9+
background-image: url("../../static/images/intro-background.svg");
10+
padding: 140px 0;
11+
background-size: cover;
12+
background-repeat: no-repeat;
13+
background-position: top;
14+
animation: 2.5s fadeInUp;
15+
width: 100%;
16+
height: 100%;
17+
top: calc(100% - 300px);
18+
z-index: -1;
19+
20+
}
21+
22+
&.page-403 {
23+
.content-wrapper {
24+
.icon {
25+
mask-image: url("./../../static/images/lock.svg");
26+
}
27+
}
28+
}
29+
30+
&.page-404 {
31+
.content-wrapper {
32+
.icon {
33+
mask-image: url("./../../static/images/not-found.svg");
34+
mask-size: 400px;
35+
}
36+
}
37+
}
38+
39+
&.page-500 {
40+
.content-wrapper {
41+
.icon {
42+
mask-image: url("./../../static/images/error.svg");
43+
}
44+
}
45+
}
46+
47+
.content-wrapper {
48+
display: flex;
49+
align-items: center;
50+
flex-direction: column;
51+
justify-content: center;
52+
height: 100%;
53+
text-align: center;
54+
animation: 2s fadeInUp;
55+
56+
.icon {
57+
display: block;
58+
width: 400px;
59+
height: 240px;
60+
background: var(--color-primary);
61+
mask-repeat: no-repeat;
62+
mask-size: contain;
63+
mask-position: center;
64+
}
65+
66+
h2 {
67+
margin: 0;
68+
font-size: 72px;
69+
}
70+
71+
p.text {
72+
margin: 0;
73+
font-size: 24px;
74+
}
75+
}
76+
}

src/static/images/error.svg

Lines changed: 5 additions & 0 deletions
Loading

src/static/images/lock.svg

Lines changed: 2 additions & 0 deletions
Loading

src/static/images/not-found.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)