Skip to content

Commit 78ddbe8

Browse files
committed
Use spline-viewer web component and load it dynamically
1 parent edf5b14 commit 78ddbe8

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

apps/webapp/app/components/ErrorDisplay.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@ import { friendlyErrorDisplay } from "~/utils/httpErrors";
55
import { LinkButton } from "./primitives/Buttons";
66
import { Header1 } from "./primitives/Headers";
77
import { Paragraph } from "./primitives/Paragraph";
8-
import Spline from "@splinetool/react-spline";
9-
import { type ReactNode } from "react";
8+
import { type ReactNode, useEffect } 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+
}
1023

1124
type ErrorDisplayOptions = {
1225
button?: {
@@ -43,6 +56,16 @@ type DisplayOptionsProps = {
4356
} & ErrorDisplayOptions;
4457

4558
export function ErrorDisplay({ title, message, button }: DisplayOptionsProps) {
59+
useEffect(() => {
60+
// Dynamically load the Spline viewer script
61+
if (!customElements.get("spline-viewer")) {
62+
const script = document.createElement("script");
63+
script.type = "module";
64+
script.src = "https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js";
65+
document.head.appendChild(script);
66+
}
67+
}, []);
68+
4669
return (
4770
<div className="relative flex min-h-screen flex-col items-center justify-center bg-[#16181C]">
4871
<div className="z-10 mt-[30vh] flex flex-col items-center gap-8">
@@ -63,7 +86,11 @@ export function ErrorDisplay({ title, message, button }: DisplayOptionsProps) {
6386
animate={{ opacity: 1 }}
6487
transition={{ delay: 0.5, duration: 2, ease: "easeOut" }}
6588
>
66-
<Spline scene="https://prod.spline.design/wRly8TZN-e0Twb8W/scene.splinecode" />
89+
<spline-viewer
90+
loading-anim-type="spinner-small-light"
91+
url="https://prod.spline.design/wRly8TZN-e0Twb8W/scene.splinecode"
92+
style={{ width: "100%", height: "100%" }}
93+
/>
6794
</motion.div>
6895
</div>
6996
);

0 commit comments

Comments
 (0)