From 61fa2267a80a432a3f00a0a1fee1c21a47014183 Mon Sep 17 00:00:00 2001 From: Manthan Terse Date: Thu, 7 May 2026 12:21:25 +0530 Subject: [PATCH] Add proper empty state before username input --- app/customize/page.tsx | 104 +++++++++++++++++++++++++++++------------ app/page.test.tsx | 15 +++++- app/page.tsx | 65 +++++++++++++++++++------- 3 files changed, 135 insertions(+), 49 deletions(-) diff --git a/app/customize/page.tsx b/app/customize/page.tsx index b2d7caa..4bd0181 100644 --- a/app/customize/page.tsx +++ b/app/customize/page.tsx @@ -139,7 +139,7 @@ function HexInput({ // ─── Main Page ──────────────────────────────────────────────────────────────── export default function CustomizePage() { - const [username, setUsername] = useState('jhasourav07'); + const [username, setUsername] = useState(''); const [theme, setTheme] = useState('dark'); const [bgHex, setBgHex] = useState(''); const [accentHex, setAccentHex] = useState(''); @@ -147,13 +147,17 @@ export default function CustomizePage() { const [scale, setScale] = useState('linear'); const [speed, setSpeed] = useState('8s'); const [copied, setCopied] = useState(false); + const trimmedUsername = username.trim(); + const hasUsername = trimmedUsername.length > 0; // ── buildQueryParams ────────────────────────────────────────────────────── const buildQueryParams = useCallback(() => { const params = new URLSearchParams(); - params.set('user', username || 'jhasourav07'); + if (hasUsername) { + params.set('user', trimmedUsername); + } const hasCustomColors = bgHex || accentHex || textHex; @@ -169,13 +173,15 @@ export default function CustomizePage() { if (speed !== '8s') params.set('speed', speed); return params.toString(); - }, [username, theme, bgHex, accentHex, textHex, scale, speed]); + }, [hasUsername, trimmedUsername, theme, bgHex, accentHex, textHex, scale, speed]); const queryString = buildQueryParams(); const previewSrc = `/api/streak?${queryString}`; const markdownSnippet = `![CommitPulse](https://commitpulse.vercel.app/api/streak?${queryString})`; const copyMarkdown = () => { + if (!hasUsername) return; + navigator.clipboard.writeText(markdownSnippet); setCopied(true); setTimeout(() => setCopied(false), 3000); @@ -417,20 +423,51 @@ export default function CustomizePage() { {/* Scanning line effect behind image */}
- {/* eslint-disable-next-line @next/next/no-img-element */} - CommitPulse live preview + {hasUsername ? ( + <> + {/* eslint-disable-next-line @next/next/no-img-element */} + CommitPulse live preview + + ) : ( +
+
+ +
+

+ Enter a GitHub username to preview +

+

+ The live badge preview will appear here once a username is added. +

+
+ )}

- Preview updates on every change · Hosted badge is cached at UTC midnight + {hasUsername + ? 'Preview updates on every change · Hosted badge is cached at UTC midnight' + : 'Add a username to enable live preview and Markdown export'}

@@ -443,10 +480,13 @@ export default function CustomizePage() { { + if (!hasUsername) e.preventDefault(); + }} + className={`relative flex min-w-[160px] items-center justify-center gap-2 overflow-hidden rounded-xl border px-6 py-3.5 text-sm font-semibold transition-all duration-200 active:scale-[0.98] ${ + hasUsername + ? 'border-[rgba(255,255,255,0.15)] bg-transparent text-white hover:bg-white/5' + : 'border-[rgba(255,255,255,0.08)] bg-white/[0.02] text-white/35' + }`} > Watch Dashboard @@ -160,16 +177,30 @@ export default function LandingPage() {
- Preview + {hasUsername ? ( + CommitPulse preview + ) : ( +
+
+ +
+

+ Enter a GitHub username to preview +

+

+ Your 3D contribution monolith will appear here as soon as you add a username. +

+
+ )}
@@ -180,7 +211,7 @@ export default function LandingPage() { {copied && ( setCopied(false)} /> )}