-
-
Notifications
You must be signed in to change notification settings - Fork 961
Fix(webapp): Dynamically load spline on 404 on page #2834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
78ddbe8
Use spline-viewer web component and load it dynamically
samejr 1835117
Remove spline react bundle dependency
samejr fdfbb07
Fix to prevent possible race condition
samejr 42b385b
Move the rotating spline logo into its own component
samejr 14ccf8d
Merge remote-tracking branch 'origin/main' into fix(webapp)-load-spli…
samejr c954411
pnpm lockfile to remove spline
samejr 8997f7c
Another fix for race condition
samejr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { motion } from "framer-motion"; | ||
| import { useEffect, useState } from "react"; | ||
|
|
||
| declare global { | ||
| namespace JSX { | ||
| interface IntrinsicElements { | ||
| "spline-viewer": React.DetailedHTMLProps< | ||
| React.HTMLAttributes<HTMLElement> & { | ||
| url?: string; | ||
| "loading-anim-type"?: string; | ||
| }, | ||
| HTMLElement | ||
| >; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export function TriggerRotatingLogo() { | ||
| const [isSplineReady, setIsSplineReady] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| // Already registered from a previous render | ||
| if (customElements.get("spline-viewer")) { | ||
| setIsSplineReady(true); | ||
| return; | ||
| } | ||
|
|
||
| const script = document.createElement("script"); | ||
| script.type = "module"; | ||
| script.src = "https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js"; | ||
| script.onload = () => setIsSplineReady(true); | ||
| // On error, we simply don't show the decorative viewer - no action needed | ||
| document.head.appendChild(script); | ||
| }, []); | ||
|
|
||
| if (!isSplineReady) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <motion.div | ||
| className="pointer-events-none absolute inset-0 overflow-hidden" | ||
| initial={{ opacity: 0 }} | ||
| animate={{ opacity: 1 }} | ||
| transition={{ delay: 0.5, duration: 2, ease: "easeOut" }} | ||
| > | ||
| <spline-viewer | ||
| loading-anim-type="spinner-small-light" | ||
| url="https://prod.spline.design/wRly8TZN-e0Twb8W/scene.splinecode" | ||
| style={{ width: "100%", height: "100%" }} | ||
| /> | ||
| </motion.div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.