Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

(www): better loading state for auth buttons at navbar (#42226)

Alan Daniel66a7255d8682
diff --git a/apps/www/components/Nav/index.tsx b/apps/www/components/Nav/index.tsx
index a8493733124..ce02b7cd8bc 100644
--- a/apps/www/components/Nav/index.tsx
+++ b/apps/www/components/Nav/index.tsx
@@ -5,7 +5,7 @@ import Link from 'next/link'
import React, { useState } from 'react'
import { useWindowSize } from 'react-use'
-import { useIsLoggedIn, useUser } from 'common'
+import { useIsLoggedIn, useIsUserLoading, useUser } from 'common'
import { Button, buttonVariants, cn } from 'ui'
import { AuthenticatedDropdownMenu } from 'ui-patterns'
@@ -50,9 +50,10 @@ const Nav = ({ hideNavbar, stickyNavbar = true }: Props) => {
const { width } = useWindowSize()
const [open, setOpen] = useState(false)
const isLoggedIn = useIsLoggedIn()
+ const isUserLoading = useIsUserLoading()
+ const user = useUser()
const menu = getMenu()
const sendTelemetryEvent = useSendTelemetryEvent()
- const user = useUser()
const userMenu = useDropdownMenu(user)
const isLaunchWeekXPage = pathname === '/launch-week/x'
@@ -148,45 +149,51 @@ const Nav = ({ hideNavbar, stickyNavbar = true }: Props) => {
</NavigationMenu>
</div>
<div className="flex items-center gap-2 opacity-0 animate-fade-in !scale-100 delay-300">
- <GitHubButton />
-
- {isLoggedIn ? (
- <>
- <Button className="hidden lg:block" asChild>
- <Link href="/dashboard/projects">Dashboard</Link>
- </Button>
- <AuthenticatedDropdownMenu menu={userMenu} user={user} site="www" />
- </>
- ) : (
- <>
- <Button type="default" className="hidden lg:block" asChild>
- <Link
- href="https://supabase.com/dashboard"
- onClick={() =>
- sendTelemetryEvent({
- action: 'sign_in_button_clicked',
- properties: { buttonLocation: 'Header Nav' },
- })
- }
- >
- Sign in
- </Link>
- </Button>
- <Button className="hidden lg:block" asChild>
- <Link
- href="https://supabase.com/dashboard"
- onClick={() =>
- sendTelemetryEvent({
- action: 'start_project_button_clicked',
- properties: { buttonLocation: 'Header Nav' },
- })
- }
- >
- Start your project
- </Link>
- </Button>
- </>
- )}
+ <div
+ className={cn(
+ 'flex items-center gap-2 transition-opacity',
+ isUserLoading ? 'opacity-0' : 'opacity-100'
+ )}
+ >
+ <GitHubButton />
+ {isLoggedIn ? (
+ <>
+ <Button className="hidden lg:block" asChild>
+ <Link href="/dashboard/projects">Dashboard</Link>
+ </Button>
+ <AuthenticatedDropdownMenu menu={userMenu} user={user} site="www" />
+ </>
+ ) : (
+ <>
+ <Button type="default" className="hidden lg:block" asChild>
+ <Link
+ href="https://supabase.com/dashboard"
+ onClick={() =>
+ sendTelemetryEvent({
+ action: 'sign_in_button_clicked',
+ properties: { buttonLocation: 'Header Nav' },
+ })
+ }
+ >
+ Sign in
+ </Link>
+ </Button>
+ <Button className="hidden lg:block" asChild>
+ <Link
+ href="https://supabase.com/dashboard"
+ onClick={() =>
+ sendTelemetryEvent({
+ action: 'start_project_button_clicked',
+ properties: { buttonLocation: 'Header Nav' },
+ })
+ }
+ >
+ Start your project
+ </Link>
+ </Button>
+ </>
+ )}
+ </div>
</div>
</div>
<HamburgerButton