Skip to content

Commit fd34566

Browse files
authored
docs: redesign Next.js quickstart sample app UI (#862)
1 parent e50fe59 commit fd34566

1 file changed

Lines changed: 89 additions & 81 deletions

File tree

main/docs/quickstart/webapp/nextjs/index.mdx

Lines changed: 89 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ APP_BASE_URL=http://localhost:3000`;
248248
return (
249249
<a
250250
href="/auth/login"
251-
className="w-full text-center inline-block px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white font-medium rounded-2xl text-[15px] tracking-[-0.01em] transition-all duration-200 hover:shadow-lg hover:shadow-blue-600/30 hover:-translate-y-px active:translate-y-0 focus:outline-none focus:ring-2 focus:ring-blue-500/50"
251+
className="w-full text-center inline-block px-6 py-3 bg-gradient-to-b from-[#2d2d42] to-[#161620] hover:opacity-90 text-white font-medium rounded-full text-[14px] transition-opacity"
252252
>
253-
Sign in with Auth0
253+
Login
254254
</a>
255255
);
256256
}
@@ -263,62 +263,53 @@ APP_BASE_URL=http://localhost:3000`;
263263
return (
264264
<a
265265
href="/auth/logout"
266-
className="w-full text-center inline-block px-6 py-3 bg-white/[0.04] hover:bg-red-500/10 text-slate-300 hover:text-red-400 font-medium rounded-2xl text-[15px] tracking-[-0.01em] border border-white/[0.08] hover:border-red-500/20 transition-all duration-200 focus:outline-none"
266+
className="w-full text-center inline-block px-6 py-3 bg-[#f0f0f0] hover:bg-gray-200 text-gray-600 font-medium rounded-full text-[14px] transition-colors"
267267
>
268-
Sign out
268+
Logout
269269
</a>
270270
);
271271
}
272272
```
273273

274-
```typescript src/components/Profile.tsx expandable lines
274+
```typescript src/components/Profile.tsx lines
275275
"use client";
276276

277277
import { useUser } from "@auth0/nextjs-auth0/client";
278278

279-
const FALLBACK_AVATAR = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%234f46e5'/%3E%3Cpath d='M50 45c7.5 0 13.64-6.14 13.64-13.64S57.5 17.72 50 17.72s-13.64 6.14-13.64 13.64S42.5 45 50 45zm0 6.82c-9.09 0-27.28 4.56-27.28 13.64v3.41c0 1.88 1.53 3.41 3.41 3.41h47.74c1.88 0 3.41-1.53 3.41-3.41v-3.41c0-9.08-18.19-13.64-27.28-13.64z' fill='%23fff'/%3E%3C/svg%3E`;
279+
function getInitials(name?: string | null, email?: string | null): string {
280+
if (name) {
281+
const parts = name.trim().split(" ");
282+
return parts.length >= 2
283+
? `${parts[0][0]}${parts[1][0]}`.toUpperCase()
284+
: parts[0].slice(0, 2).toUpperCase();
285+
}
286+
if (email) return email.slice(0, 2).toUpperCase();
287+
return "U";
288+
}
280289

281290
export default function Profile() {
282291
const { user, isLoading } = useUser();
283292

284-
if (isLoading) {
285-
return (
286-
<div className="flex items-center gap-3 w-full bg-white/[0.03] rounded-2xl p-4 border border-white/[0.06]">
287-
<div className="w-12 h-12 rounded-full bg-white/10 animate-pulse shrink-0" />
288-
<div className="flex-1 space-y-2">
289-
<div className="h-3.5 bg-white/10 rounded-full animate-pulse w-2/3" />
290-
<div className="h-3 bg-white/10 rounded-full animate-pulse w-1/2" />
291-
</div>
292-
</div>
293-
);
294-
}
295-
293+
if (isLoading) return <p className="text-xs text-gray-500">Loading...</p>;
296294
if (!user) return null;
297295

298296
return (
299-
<div className="flex items-center gap-4 w-full bg-white/[0.03] rounded-2xl p-4 border border-white/[0.06]">
300-
<div className="relative shrink-0">
301-
<div className="p-[2px] rounded-full bg-gradient-to-br from-blue-400 to-violet-500">
302-
<img
303-
src={user.picture || FALLBACK_AVATAR}
304-
alt={user.name || "User"}
305-
referrerPolicy="no-referrer"
306-
className="w-11 h-11 rounded-full object-cover bg-slate-900 block"
307-
onError={(e) => {
308-
(e.target as HTMLImageElement).src = FALLBACK_AVATAR;
309-
}}
310-
/>
311-
</div>
312-
<span className="absolute -bottom-0.5 -right-0.5 w-3.5 h-3.5 bg-green-400 rounded-full border-2 border-[#060812]" />
297+
<>
298+
<div className="flex items-center gap-2 text-green-500 text-[13px] font-medium">
299+
<span className="w-5 h-5 bg-green-500 rounded-full flex items-center justify-center shrink-0">
300+
<svg width="10" height="8" viewBox="0 0 10 8" fill="none">
301+
<path d="M1 4L3.5 6.5L9 1" stroke="white" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
302+
</svg>
303+
</span>
304+
Successfully authenticated
313305
</div>
314-
<div className="flex-1 min-w-0">
315-
<p className="text-white text-sm font-semibold truncate">{user.name}</p>
316-
<p className="text-slate-400 text-xs truncate mt-0.5">{user.email}</p>
306+
<div className="flex items-center gap-2 bg-gray-100 rounded-full py-1.5 pl-1.5 pr-4 text-[12px] text-gray-700 max-w-full">
307+
<span className="w-7 h-7 bg-gradient-to-b from-[#2d2d42] to-[#161620] rounded-full flex items-center justify-center text-white text-[10px] font-semibold shrink-0">
308+
{getInitials(user.name, user.email)}
309+
</span>
310+
<span className="truncate">{user.email}</span>
317311
</div>
318-
<span className="shrink-0 text-xs px-2 py-0.5 rounded-full bg-green-400/10 text-green-400 border border-green-400/20 font-medium">
319-
Active
320-
</span>
321-
</div>
312+
</>
322313
);
323314
}
324315
```
@@ -328,7 +319,7 @@ APP_BASE_URL=http://localhost:3000`;
328319
<Step title="Update your main page" stepNumber={8}>
329320
Replace `src/app/page.tsx` with:
330321

331-
```typescript src/app/page.tsx expandable lines
322+
```typescript src/app/page.tsx lines
332323
import { auth0 } from "@/lib/auth0";
333324
import LoginButton from "@/components/LoginButton";
334325
import LogoutButton from "@/components/LogoutButton";
@@ -339,47 +330,64 @@ APP_BASE_URL=http://localhost:3000`;
339330
const user = session?.user;
340331

341332
return (
342-
<main className="min-h-screen bg-[#060812] flex items-center justify-center px-6 py-12 relative overflow-hidden">
343-
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-[600px] md:w-[900px] h-[300px] md:h-[450px] bg-blue-600/20 rounded-full blur-3xl pointer-events-none" />
344-
<div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-[400px] md:w-[600px] h-[200px] md:h-[300px] bg-violet-600/15 rounded-full blur-3xl pointer-events-none" />
345-
346-
<div className="relative w-full max-w-sm md:max-w-md">
347-
<div className="bg-white/[0.04] backdrop-blur-2xl border border-white/[0.08] rounded-3xl shadow-2xl shadow-black/60 overflow-hidden">
348-
<div className="h-px bg-gradient-to-r from-transparent via-blue-500/60 to-transparent" />
349-
350-
<div className="px-8 md:px-10 pt-9 md:pt-10 pb-9 md:pb-10 flex flex-col items-center gap-6 md:gap-7">
351-
<img
352-
src="https://cdn.auth0.com/quantum-assets/dist/latest/logos/auth0/auth0-lockup-en-ondark.png"
353-
alt="Auth0"
354-
className="h-6 md:h-7"
355-
/>
356-
357-
<div className="text-center">
358-
<h1 className="text-xl md:text-2xl font-semibold text-white tracking-[-0.02em]">
359-
Next.js + Auth0
360-
</h1>
361-
<p className="text-slate-500 text-sm md:text-[15px] mt-1.5">
362-
Secure, simple authentication
363-
</p>
364-
</div>
365-
366-
<div className="w-full h-px bg-white/[0.06]" />
367-
368-
{user ? (
369-
<div className="flex flex-col items-center gap-4 w-full">
370-
<Profile />
371-
<LogoutButton />
372-
</div>
373-
) : (
374-
<div className="flex flex-col items-center gap-5 w-full">
375-
<p className="text-slate-400 text-sm md:text-[15px] text-center leading-relaxed tracking-[-0.01em]">
376-
Sign in to access your account and protected content.
377-
</p>
378-
<LoginButton />
379-
</div>
380-
)}
381-
</div>
382-
</div>
333+
<main className="min-h-screen bg-[#efefef] flex flex-col items-center justify-center gap-4 px-6 py-12">
334+
<div className="bg-white rounded-[28px] shadow-[0_4px_32px_rgba(0,0,0,0.08)] px-12 py-14 flex flex-col items-center gap-4 w-[360px]">
335+
<svg width="68" height="68" viewBox="0 0 68 68" fill="none" xmlns="http://www.w3.org/2000/svg" className="mb-1">
336+
<g filter="url(#filter0_di)">
337+
<rect x="2" y="2" width="64" height="64" rx="16" fill="url(#paint0_linear)"/>
338+
<rect x="2.5" y="2.5" width="63" height="63" rx="15.5" stroke="#252525"/>
339+
<path d="M34.0002 18C25.1572 18 18 25.1669 18 34C18 42.8432 25.1672 50 34.0002 50C42.8333 50 50 42.8331 50 34C50 25.1669 42.8433 18 34.0002 18ZM43.9172 43.8971C43.9172 43.9071 43.9069 43.9072 43.9069 43.9172C43.9069 43.9172 43.8969 43.9272 43.8868 43.9272C43.144 44.65 41.9796 44.7303 41.0662 44.2585L40.0228 43.7265C36.2487 41.7792 31.7619 41.7792 27.9777 43.7265L26.9338 44.2585C26.0103 44.7303 24.8459 44.65 24.1132 43.9272C24.1132 43.9272 24.1031 43.9172 24.0931 43.9172C24.0931 43.9172 24.0828 43.9071 24.0828 43.8971C23.3601 43.1543 23.2797 41.9899 23.7515 41.0765L24.2837 40.0326C26.231 36.2585 26.231 31.7717 24.2837 27.9975L23.7515 26.9536C23.2797 26.0302 23.3601 24.8657 24.0828 24.133C24.0828 24.1229 24.0931 24.123 24.0931 24.123C24.0931 24.123 24.1031 24.1129 24.1132 24.1129C24.856 23.3902 26.0204 23.3099 26.9338 23.7817L27.9777 24.3137C31.7518 26.261 36.2386 26.261 40.0228 24.3137L41.0662 23.7817C41.9897 23.3099 43.1541 23.3902 43.8868 24.1129C43.8868 24.1129 43.8969 24.123 43.9069 24.123L43.9172 24.133C44.6399 24.8758 44.7203 26.0402 44.2485 26.9536L43.7163 27.9975C41.769 31.7717 41.769 36.2585 43.7163 40.0326L44.2485 41.0765C44.7203 41.9899 44.6499 43.1543 43.9172 43.8971Z" fill="white"/>
340+
</g>
341+
<defs>
342+
<filter id="filter0_di" x="0" y="0" width="68" height="68" filterUnits="userSpaceOnUse" colorInterpolationFilters="sRGB">
343+
<feFlood floodOpacity="0" result="BackgroundImageFix"/>
344+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
345+
<feMorphology radius="2" operator="dilate" in="SourceAlpha" result="effect1_dropShadow"/>
346+
<feOffset/>
347+
<feComposite in2="hardAlpha" operator="out"/>
348+
<feColorMatrix type="matrix" values="0 0 0 0 0.117647 0 0 0 0 0.129412 0 0 0 0 0.164706 0 0 0 0.12 0"/>
349+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
350+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
351+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
352+
<feOffset dy="-1"/>
353+
<feGaussianBlur stdDeviation="0.5"/>
354+
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
355+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0"/>
356+
<feBlend mode="normal" in2="shape" result="effect2_innerShadow"/>
357+
</filter>
358+
<linearGradient id="paint0_linear" x1="34" y1="2" x2="34" y2="66" gradientUnits="userSpaceOnUse">
359+
<stop/>
360+
<stop offset="1" stopColor="#677190"/>
361+
</linearGradient>
362+
</defs>
363+
</svg>
364+
365+
{user ? (
366+
<>
367+
<h1 className="text-[17px] font-bold text-gray-900 tracking-tight">Your account</h1>
368+
<div className="w-full h-px bg-gray-100" />
369+
<Profile />
370+
<LogoutButton />
371+
</>
372+
) : (
373+
<>
374+
<h1 className="text-[17px] font-bold text-gray-900 tracking-tight">Welcome to Sample0</h1>
375+
<p className="text-[13px] text-gray-400 text-center leading-relaxed -mt-2">
376+
Get started by logging in to your account
377+
</p>
378+
<div className="h-3" />
379+
<LoginButton />
380+
</>
381+
)}
382+
</div>
383+
384+
<div className="flex items-center gap-1.5 text-[11px] text-gray-400">
385+
<span>Powered by</span>
386+
<img
387+
src="https://cdn.auth0.com/quantum-assets/dist/latest/logos/auth0/auth0-lockup-en-onlight.svg"
388+
alt="Auth0"
389+
className="h-3 opacity-40"
390+
/>
383391
</div>
384392
</main>
385393
);

0 commit comments

Comments
 (0)