refactor: improve 404 page loading experience and styling

- Replace Suspense with useEffect for better control over component mounting.
- Update loading indicators with fixed positioning and enhanced styling for a terminal-like appearance.
- Modify KernelPanic404 component to improve text color handling and ensure proper visibility.
- Introduce checks for 404 page detection based on pathname and data attributes for more accurate rendering.
This commit is contained in:
2026-01-10 03:41:22 +01:00
parent 59cc8ee154
commit 20f0ccb85b
5 changed files with 1865 additions and 44 deletions

View File

@@ -1,30 +1,80 @@
"use client";
import { Suspense } from "react";
import { useEffect, useState } from "react";
import dynamic from "next/dynamic";
// Dynamically import KernelPanic404 to avoid SSR issues
const KernelPanic404 = dynamic(() => import("./components/KernelPanic404"), {
// Dynamically import KernelPanic404Wrapper to avoid SSR issues
const KernelPanic404 = dynamic(() => import("./components/KernelPanic404Wrapper"), {
ssr: false,
loading: () => (
<div className="flex items-center justify-center min-h-screen bg-black text-[#33ff00] font-mono">
<div style={{
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "#020202",
color: "#33ff00",
fontFamily: "monospace"
}}>
<div>Loading terminal...</div>
</div>
),
});
export default function NotFound() {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return (
<div style={{
position: "fixed",
top: 0,
left: 0,
width: "100vw",
height: "100vh",
margin: 0,
padding: 0,
overflow: "hidden",
backgroundColor: "#020202",
zIndex: 9998
}}>
<div style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
width: "100%",
height: "100%",
color: "#33ff00",
fontFamily: "monospace"
}}>
Loading terminal...
</div>
</div>
);
}
return (
<main className="min-h-screen w-full bg-black overflow-hidden relative">
<Suspense
fallback={
<div className="flex items-center justify-center min-h-screen bg-black text-[#33ff00] font-mono">
<div>Loading terminal...</div>
</div>
}
>
<KernelPanic404 />
</Suspense>
</main>
<div style={{
position: "fixed",
top: 0,
left: 0,
width: "100vw",
height: "100vh",
margin: 0,
padding: 0,
overflow: "hidden",
backgroundColor: "#020202",
zIndex: 9998
}}>
<KernelPanic404 />
</div>
);
}