Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Friendly 404 and error screens, roomier narrow stages

Youssef4a809b67f70f
diff --git a/src/app/error.tsx b/src/app/error.tsx
new file mode 100644
index 0000000..0c1936f
--- /dev/null
+++ b/src/app/error.tsx
@@ -0,0 +1,27 @@
+"use client";
+
+import Link from "next/link";
+import { useEffect } from "react";
+import { Figure } from "@/components/art/Figure";
+
+/** Something broke while drawing a page: say so plainly and offer a way out. */
+export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
+ useEffect(() => {
+ console.error(error);
+ }, [error]);
+ return (
+ <main className="lost">
+ <Figure pose="think" bubble="!" size={120} />
+ <h1>A part didn&apos;t fit</h1>
+ <p className="lead">Something went wrong on our side. Your progress is saved on this device.</p>
+ <div className="lost-actions">
+ <button className="btn primary" onClick={reset}>
+ Try again
+ </button>
+ <Link href="/" className="btn ghost">
+ Back to search
+ </Link>
+ </div>
+ </main>
+ );
+}
diff --git a/src/app/home.css b/src/app/home.css
index fd26dc5..5709736 100644
--- a/src/app/home.css
+++ b/src/app/home.css
@@ -1806,3 +1806,36 @@
opacity: 1;
}
}
+
+/* ================= lost: 404 and errors ================= */
+
+.lost {
+ display: grid;
+ justify-items: center;
+ gap: 14px;
+ max-width: 560px;
+ margin: 0 auto;
+ padding: 64px 0 96px;
+ text-align: center;
+}
+.lost h1 {
+ margin: 12px 0 0;
+ font-family: var(--display);
+ font-size: clamp(32px, 6vw, 46px);
+ font-weight: 800;
+ letter-spacing: -0.03em;
+ line-height: 1.05;
+}
+.lost .lead {
+ margin: 0;
+}
+.lost-search {
+ width: 100%;
+ margin-top: 10px;
+ text-align: left;
+}
+.lost-actions {
+ display: flex;
+ gap: 10px;
+ margin-top: 12px;
+}
diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx
new file mode 100644
index 0000000..233a2b1
--- /dev/null
+++ b/src/app/not-found.tsx
@@ -0,0 +1,25 @@
+import Link from "next/link";
+import SiteHeader from "@/components/SiteHeader";
+import SiteFooter from "@/components/SiteFooter";
+import { Figure } from "@/components/art/Figure";
+import { HeroSearch } from "@/components/home/HomeClient";
+
+export default function NotFound() {
+ return (
+ <div className="site">
+ <SiteHeader />
+ <main className="lost">
+ <Figure pose="think" bubble="?" size={120} />
+ <h1>This page isn&apos;t in the box</h1>
+ <p className="lead">The link may be old. Type the name from your box instead, or browse every guide.</p>
+ <div className="lost-search">
+ <HeroSearch />
+ </div>
+ <Link href="/browse" className="sec-link">
+ All guides
+ </Link>
+ </main>
+ <SiteFooter />
+ </div>
+ );
+}
diff --git a/src/engine/stage.ts b/src/engine/stage.ts
index 8f6c73f..b5de218 100644
--- a/src/engine/stage.ts
+++ b/src/engine/stage.ts
@@ -871,9 +871,9 @@ export class Stage {
} else if (k === "step") {
const co = this.callout && this.focus ? this.callout.size + (mob ? 24 : 56) : 0;
mT = (mob ? 70 : 96) + m.t;
- mL = (mob ? 18 : 36) + m.l;
+ mL = (mob ? 24 : 36) + m.l;
mB = (mob ? 56 : 72) + m.b;
- mR = Math.max(mob ? 18 : 36, co * (mob ? 0.55 : 1)) + m.r;
+ mR = Math.max(mob ? 24 : 36, co * (mob ? 0.55 : 1)) + m.r;
} else if (k === "part") {
mT = mR = mB = mL = 4;
} else if (k === "layout") {
@@ -904,7 +904,7 @@ export class Stage {
first = false;
if (k === "step" && this.callout && this.focus) {
// the circle only blocks the top right corner: try keeping the drawing below it instead
- const below = fit(l, Math.max(t, this.callout.size + 34), (mob ? 18 : 36) + m.r, mB);
+ const below = fit(l, Math.max(t, this.callout.size + 34), (mob ? 24 : 36) + m.r, mB);
if (below.s < best.s) best = below;
}
}