Skip to content

Commit 26c101a

Browse files
committed
Trigger error on 500 and 404 and style it
1 parent 820999f commit 26c101a

File tree

6 files changed

+65
-12
lines changed

6 files changed

+65
-12
lines changed

src/pages/_app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { Open_Sans } from 'next/font/google';
44
import type { AppProps } from 'next/app';
55
import Head from "next/head";
66

7-
import '@/styles/main.css';
87
import Header from "@/components/navigation/Header";
98
import Footer from "@/components/navigation/Footer";
109

10+
import '@/styles/main.css';
11+
1112
const openSans = Open_Sans({
1213
subsets: ['latin'],
1314
variable: "--font-open-sans"

src/styles/main.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@ body,
1010
}
1111

1212
html {
13-
@apply bg-fill text-fill-contrast
13+
@apply bg-fill text-fill-contrast;
14+
}
15+
16+
div.swal2-popup.swal2-toast {
17+
@apply p-3 shadow shadow-black/25 bg-white/50 backdrop-blur-sm;
18+
}
19+
20+
div.swal2-popup.swal2-toast .swal2-title {
21+
@apply m-0 text-black;
22+
}
23+
24+
div.swal2-popup.swal2-toast .swal2-html-container {
25+
@apply m-0 text-black;
26+
}
27+
28+
div.swal2-popup.swal2-toast .swal2-icon {
29+
@apply mr-4;
1430
}

src/utils/swal.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import Swal from "sweetalert2";
22
import withReactContent from "sweetalert2-react-content";
3+
const swal = withReactContent(Swal).mixin({
4+
customClass: {
5+
icon: "mr-4"
6+
}
7+
});
38

4-
const swal = withReactContent(Swal);
9+
export const toast = swal.mixin({
10+
timer: 5000,
11+
timerProgressBar: true,
12+
position: "top",
13+
showConfirmButton: false,
14+
toast: true,
15+
didOpen: (toast) => {
16+
toast.addEventListener('mouseenter', Swal.stopTimer);
17+
toast.addEventListener('mouseleave', Swal.resumeTimer);
18+
},
19+
customClass: {
20+
21+
}
22+
});
523

624
export default swal;

src/utils/wretch.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/utils/wretch.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import wretch from "wretch";
2+
import { toast } from "./swal";
3+
4+
export const backend = wretch(process.env.NEXT_PUBLIC_BACKEND_URL!)
5+
.options({
6+
mode: "cors"
7+
})
8+
.catcher(404, () => toast.fire({
9+
title: "Error",
10+
icon: "error",
11+
text: "Resource was not found."
12+
}))
13+
.catcher(500, () => toast.fire({
14+
title: "Error",
15+
icon: "error",
16+
text: "Internal Server Error, try again later."
17+
}));

tailwind.config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
const plugin = require("tailwindcss/plugin");
12
const { fontFamily } = require('tailwindcss/defaultTheme');
23

3-
44
/** @type {import('tailwindcss').Config} */
55
module.exports = {
66
content: [
77
"./src/pages/**/*.tsx",
88
"./src/components/**/*.tsx",
9+
"./src/utils/**/*.{ts,tsx}"
910
],
1011
theme: {
1112
extend: {
@@ -14,7 +15,7 @@ module.exports = {
1415
},
1516
colors: {
1617
primary: {
17-
DEFAULT: "#FF5C00",
18+
DEFAULT: "#f2600c",
1819
light: "#FF792E",
1920
dark: "#DB5103",
2021
contrast: "#FFF"
@@ -26,7 +27,7 @@ module.exports = {
2627
contrast: "#FFF"
2728
},
2829
fill: {
29-
DEFAULT: "#FFDFC1",
30+
DEFAULT: "#FFE4CC",
3031
contrast: "#282828"
3132
}
3233
},
@@ -35,5 +36,10 @@ module.exports = {
3536
}
3637
},
3738
},
38-
plugins: [],
39+
plugins: [
40+
plugin(({ addVariant }) => {
41+
addVariant("is", ":is(&)");
42+
addVariant("where", ":where(&)");
43+
})
44+
],
3945
};

0 commit comments

Comments
 (0)