Skip to content

Commit 42b385b

Browse files
committed
Move the rotating spline logo into its own component
1 parent fdfbb07 commit 42b385b

File tree

2 files changed

+57
-47
lines changed

2 files changed

+57
-47
lines changed
Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import { HomeIcon } from "@heroicons/react/20/solid";
22
import { isRouteErrorResponse, useRouteError } from "@remix-run/react";
3-
import { motion } from "framer-motion";
43
import { friendlyErrorDisplay } from "~/utils/httpErrors";
54
import { LinkButton } from "./primitives/Buttons";
65
import { Header1 } from "./primitives/Headers";
76
import { Paragraph } from "./primitives/Paragraph";
8-
import { type ReactNode, useEffect, useState } from "react";
9-
10-
declare global {
11-
namespace JSX {
12-
interface IntrinsicElements {
13-
"spline-viewer": React.DetailedHTMLProps<
14-
React.HTMLAttributes<HTMLElement> & {
15-
url?: string;
16-
"loading-anim-type"?: string;
17-
},
18-
HTMLElement
19-
>;
20-
}
21-
}
22-
}
7+
import { TriggerRotatingLogo } from "./TriggerRotatingLogo";
8+
import { type ReactNode } from "react";
239

2410
type ErrorDisplayOptions = {
2511
button?: {
@@ -56,23 +42,6 @@ type DisplayOptionsProps = {
5642
} & ErrorDisplayOptions;
5743

5844
export function ErrorDisplay({ title, message, button }: DisplayOptionsProps) {
59-
const [isSplineReady, setIsSplineReady] = useState(false);
60-
61-
useEffect(() => {
62-
// Already registered from a previous render
63-
if (customElements.get("spline-viewer")) {
64-
setIsSplineReady(true);
65-
return;
66-
}
67-
68-
const script = document.createElement("script");
69-
script.type = "module";
70-
script.src = "https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js";
71-
script.onload = () => setIsSplineReady(true);
72-
// On error, we simply don't show the decorative viewer - no action needed
73-
document.head.appendChild(script);
74-
}, []);
75-
7645
return (
7746
<div className="relative flex min-h-screen flex-col items-center justify-center bg-[#16181C]">
7847
<div className="z-10 mt-[30vh] flex flex-col items-center gap-8">
@@ -87,20 +56,7 @@ export function ErrorDisplay({ title, message, button }: DisplayOptionsProps) {
8756
{button ? button.title : "Go to homepage"}
8857
</LinkButton>
8958
</div>
90-
{isSplineReady && (
91-
<motion.div
92-
className="pointer-events-none absolute inset-0 overflow-hidden"
93-
initial={{ opacity: 0 }}
94-
animate={{ opacity: 1 }}
95-
transition={{ delay: 0.5, duration: 2, ease: "easeOut" }}
96-
>
97-
<spline-viewer
98-
loading-anim-type="spinner-small-light"
99-
url="https://prod.spline.design/wRly8TZN-e0Twb8W/scene.splinecode"
100-
style={{ width: "100%", height: "100%" }}
101-
/>
102-
</motion.div>
103-
)}
59+
<TriggerRotatingLogo />
10460
</div>
10561
);
10662
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { motion } from "framer-motion";
2+
import { useEffect, useState } from "react";
3+
4+
declare global {
5+
namespace JSX {
6+
interface IntrinsicElements {
7+
"spline-viewer": React.DetailedHTMLProps<
8+
React.HTMLAttributes<HTMLElement> & {
9+
url?: string;
10+
"loading-anim-type"?: string;
11+
},
12+
HTMLElement
13+
>;
14+
}
15+
}
16+
}
17+
18+
export function TriggerRotatingLogo() {
19+
const [isSplineReady, setIsSplineReady] = useState(false);
20+
21+
useEffect(() => {
22+
// Already registered from a previous render
23+
if (customElements.get("spline-viewer")) {
24+
setIsSplineReady(true);
25+
return;
26+
}
27+
28+
const script = document.createElement("script");
29+
script.type = "module";
30+
script.src = "https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js";
31+
script.onload = () => setIsSplineReady(true);
32+
// On error, we simply don't show the decorative viewer - no action needed
33+
document.head.appendChild(script);
34+
}, []);
35+
36+
if (!isSplineReady) {
37+
return null;
38+
}
39+
40+
return (
41+
<motion.div
42+
className="pointer-events-none absolute inset-0 overflow-hidden"
43+
initial={{ opacity: 0 }}
44+
animate={{ opacity: 1 }}
45+
transition={{ delay: 0.5, duration: 2, ease: "easeOut" }}
46+
>
47+
<spline-viewer
48+
loading-anim-type="spinner-small-light"
49+
url="https://prod.spline.design/wRly8TZN-e0Twb8W/scene.splinecode"
50+
style={{ width: "100%", height: "100%" }}
51+
/>
52+
</motion.div>
53+
);
54+
}

0 commit comments

Comments
 (0)