Skip to content

Commit d70a4b8

Browse files
authored
feat(not-found): add click-to-copy functionality to 404 terminal (JhaSourav07#1880)
## Description Fixes JhaSourav07#1798 This PR adds click-to-copy functionality to the custom 404 terminal page, making the terminal block interactive and allowing users to easily copy the displayed terminal output. ### Changes Made * Added clipboard copy support using `navigator.clipboard.writeText()` * Added success notification using the existing Sonner toast system * Added error handling for clipboard failures * Added hover and pointer states to indicate clickability * Added a "Click to copy" indicator in the terminal header * Preserved the existing UI and terminal aesthetics ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Checklist * [x] I have read the CONTRIBUTING.md file * [x] I have tested these changes locally * [x] I have run formatting and build checks * [x] My commit follows the Conventional Commits format * [x] This change does not introduce breaking changes * [x] The UI remains consistent with the existing design system ## Visual Preview ### Before Users had to manually highlight and copy terminal content. ### After Users can click anywhere on the terminal block to instantly copy the terminal output and receive visual feedback through a toast notification. ### Screenshots <img width="1920" height="1020" alt="Screenshot 2026-05-31 004706" src="https://github.com/user-attachments/assets/69cee3c7-093e-492e-8f94-35531580ecf6" /> <img width="1707" height="744" alt="Screenshot 2026-05-31 004728" src="https://github.com/user-attachments/assets/1bc756d3-ecdb-4944-80f1-c1e7661cd361" />
2 parents 1812392 + 3ceb656 commit d70a4b8

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

app/not-found.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1+
'use client';
12
import Link from 'next/link';
23

4+
import { toast } from 'sonner';
35
export default function NotFound() {
6+
const terminalContent = `git checkout this-page
7+
8+
The page you're looking for has been rebased out of existence. No stash. No reflog. Just vibes.
9+
10+
hint: Did you mean some other username?`;
11+
12+
const handleCopy = async () => {
13+
try {
14+
await navigator.clipboard.writeText(terminalContent);
15+
toast.success('Terminal output copied!');
16+
} catch {
17+
toast.error('Failed to copy terminal output');
18+
}
19+
};
20+
421
return (
5-
<main className="relative min-h-screen text-white overflow-hidden flex flex-col items-center font-sans ">
22+
<main className="relative min-h-screen text-white overflow-hidden flex flex-col items-center font-sans">
623
<div
724
aria-hidden="true"
825
className="pointer-events-none fixed inset-0"
@@ -14,8 +31,8 @@ export default function NotFound() {
1431
/>
1532

1633
<div aria-hidden="true" className="pointer-events-none absolute inset-0 overflow-hidden">
17-
<div className="absolute top-[-10%] left-[20%] h-screen w-screen rounded-full blur-[140px]" />
18-
<div className="absolute bottom-[-10%] right-[15%] h-screen w-screen rounded-full blur-[120px]" />
34+
<div className="absolute top-[-10%] left-[20%] h-screen w-screen rounded-full blur-[140px]" />
35+
<div className="absolute bottom-[-10%] right-[15%] h-screen w-screen rounded-full blur-[120px]" />
1936
</div>
2037

2138
<div className="relative z-10 flex flex-col items-center justify-start gap-8 max-w-lg w-full text-center">
@@ -38,12 +55,16 @@ export default function NotFound() {
3855
</h1>
3956
</div>
4057

41-
<div className="w-full rounded-2xl border border-white/10 bg-white/3 backdrop-blur-md overflow-hidden ">
58+
<div
59+
onClick={handleCopy}
60+
className="w-full rounded-2xl border border-white/10 bg-white/3 backdrop-blur-md overflow-hidden cursor-pointer hover:bg-white/5 transition-all duration-200"
61+
>
4262
<div className="flex items-center gap-2 border-b border-white/10 bg-white/4 px-4 py-3">
4363
<span className="h-3 w-3 rounded-full bg-red-500/70" />
4464
<span className="h-3 w-3 rounded-full bg-yellow-500/70" />
4565
<span className="h-3 w-3 rounded-full bg-green-500/70" />
4666
<span className="ml-3 text-xs font-mono text-white/30">commitpulse — bash</span>
67+
<span className="ml-auto text-xs text-white/40">Click to copy</span>
4768
</div>
4869

4970
<div className="px-6 py-5 font-mono text-sm text-left space-y-2">
@@ -54,12 +75,14 @@ export default function NotFound() {
5475
git checkout <span className="text-cyan-400">this-page</span>
5576
</span>
5677
</p>
57-
<p className="text-red-400/80 ">
58-
{' '}
78+
79+
<p className="text-red-400/80">
5980
The page you&apos;re looking for has been rebased out of existence. No stash. No
6081
reflog. Just vibes.
6182
</p>
83+
6284
<p className="text-white/30 text-xs mt-1">hint: Did you mean some other username?</p>
85+
6386
<p className="flex items-center gap-1 pt-1">
6487
<span className="text-violet-400">~</span>
6588
<span className="text-white/40"> $ </span>
@@ -81,15 +104,14 @@ export default function NotFound() {
81104
>
82105
git checkout main
83106
</Link>
107+
84108
<Link
85109
href="/"
86110
className="flex-1 py-3 rounded-xl font-semibold text-sm text-white/60 text-center border border-white/10 hover:bg-white/5 hover:text-white transition-all"
87111
>
88112
Go back home
89113
</Link>
90114
</div>
91-
92-
{/* <p className="text-white/20 text-xs font-mono">exit code 404 · no such file or directory</p> */}
93115
</div>
94116
</main>
95117
);

0 commit comments

Comments
 (0)