Files
supabase/apps/www/components/Nav/index.tsx
Saxon FletcherandDanny White cd77bebafd chore(ui): refresh shared button styles (#50197)
## What kind of change does this PR introduce?

UI polish / design system: refreshed button styles, related token
tweaks, and a shared floating-button plate.

Resolves DEPR-652.

## What is the current behavior?

Default, primary, and secondary buttons use older fills, borders, and
hover treatments. Primary still leans on brand scale utilities. Default
fills don’t always read as raised chrome across surfaces, and floating
copy / expand / scroll controls can let busy content show through
translucent fills. Call sites hand-roll `rounded-* bg-background`
wrappers for that.

## What is the new behavior?

Refreshes primary, default, and secondary buttons with medium-weight
labels, subtle shadows and inset edges, and smoother transitions.
Light-mode default buttons use a raised fill with an accent hover state,
primary text is brighter, and inline keyboard shortcuts inherit the
button’s colour.

Adds `FloatingPlate`: an opaque `bg-popover` shell for floating default
buttons (and small clusters). Migrates Studio, Docs-related patterns,
www, and `ui-patterns` floaters onto it so busy content no longer shows
through translucent fills. Positioning, z-index, and hover/focus reveal
stay on the plate’s `className`. Use `rounded="full"` for pills.

Also:

- Moves primary onto semantic `--primary` / `--primary-hover` (with a
light-theme override) instead of brand utility fills
- Tokenises button shadows as `--button-shadow-drop` /
`--button-shadow-raised` / `--button-shadow-default` on the Button base
- Aligns hover direction: darken on light mode, lighten on dark mode for
both default and primary
- Default fill stays opaque `bg-card` in light (occlusion) and
translucent `bg-muted` in dark (adapts to the local surface)
- Documents fills and `FloatingPlate` on the design-system Button page
(with a live example)
- Scales shared radius tokens in Studio and www; medium+ Button sizes
use a proportionally softer radius
- Fixes www nav CTA centering (`lg:inline-flex` instead of `lg:block`)
- Query detail Expand/Collapse wires `aria-expanded` / `aria-controls`

| Before | After |
| --- | --- |
| <img width="1074" height="438" alt="CleanShot 2026-09-18 at 15 52
51@2x"
src="https://github.com/user-attachments/assets/ef43da21-b053-4b7e-9ac4-ab8b428228ab"
/> | <img width="1090" height="464" alt="CleanShot 2026-09-18 at 15 50
59@2x"
src="https://github.com/user-attachments/assets/2ddc55fc-4c8d-499c-a280-f3db3d99023c"
/> |
| <img width="1082" height="446" alt="CleanShot 2026-09-18 at 15 52
35@2x"
src="https://github.com/user-attachments/assets/3dd5452d-325a-4e4a-a79d-26c6c6950a31"
/> | <img width="1078" height="446" alt="CleanShot 2026-09-18 at 15 51
13@2x"
src="https://github.com/user-attachments/assets/93666385-3e6e-42e0-9891-9cd6bb935b67"
/> |

## To test

### Design system

- [Button
page](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button):
default / primary in light and dark; hover should darken on light,
lighten on dark
- Same page: [Floating over
content](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button#floating-over-content)
/ [Floating
plate](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button#floating-plate)
example; Copy over SQL should stay opaque
- Spot-check hover on a code preview Copy control

### Docs

[Docs deploy
preview](https://docs-git-chore-button-styles-supabase.vercel.app/docs):

- [Docs
homepage](https://docs-git-chore-button-styles-supabase.vercel.app/docs):
top-right **Sign up** / **Dashboard** primary; menu icon beside it
(default icon button)
- Shrink below `lg` and open the hamburger drawer: bottom **Sign in**
(default) + **Start your project** (primary) medium block buttons
- Tab once for **Skip to content** (FloatingPlate)
- [MCP
guide](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/ai-tools/mcp):
project picker
- [Apple
login](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/auth/social-login/auth-apple):
**Generate Secret Key** button in the Apple Secret Generator
- Optional opacity check: any guide code block Copy control (e.g. at the
bottom of [Import data into
Supabase](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/database/import-data))

### Studio

[Studio deploy
preview](https://studio-staging-git-chore-button-styles-supabase.vercel.app/):

- **Observability → Query Performance**: open a query detail →
Expand/Collapse pill + SQL Copy chip (dark: no bleed-through)
- **Observability → Query Insights**: select a query → Clear query pill
- **Table Editor → any table → Definition** → floating **Open in SQL
Editor**
- **Connect → Framework → Add files**: Copy on the code tabs
(FloatingPlate; light hover follow-up is DEPR-694)
- Tab once for **Skip to content**

### WWW

- [www deploy
preview](https://zone-www-dot-com-git-chore-button-styles-supabase.vercel.app/):
nav Sign in / Start your project vertical centering; hero medium CTAs
radius

---------

Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-09-23 03:43:00 +00:00

273 lines
11 KiB
TypeScript

'use client'
import { useIsLoggedIn, useIsUserLoading, useUser } from 'common'
import ScrollProgress from 'components/ScrollProgress'
import { getMenu } from 'data/nav'
import { DevToolbarTrigger } from 'dev-tools'
import { useSendTelemetryEvent } from 'lib/telemetry'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import React, { useState } from 'react'
import { useWindowSize } from 'react-use'
import {
Button,
buttonVariants,
cn,
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
NavigationMenuViewport,
} from 'ui'
import { AuthenticatedDropdownMenu } from 'ui-patterns/AuthenticatedDropdownMenu'
import { AnnouncementBanner } from 'ui-patterns/Banners/AnnouncementBanner'
import GitHubButton from './GitHubButton'
import HamburgerButton from './HamburgerMenu'
import MenuItem from './MenuItem'
import { MobileMenu } from './MobileMenu'
import RightClickBrandLogo from './RightClickBrandLogo'
import useDropdownMenu from './useDropdownMenu'
interface Props {
hideNavbar: boolean
stickyNavbar?: boolean
}
const Nav = ({ hideNavbar, stickyNavbar = true }: Props) => {
const pathname = usePathname()
const { width } = useWindowSize()
const [open, setOpen] = useState(false)
const [activeDropdown, setActiveDropdown] = useState('')
const [visibleDropdown, setVisibleDropdown] = useState('')
const [isSwitchingDropdown, setIsSwitchingDropdown] = useState(false)
const [openedDropdowns, setOpenedDropdowns] = useState<string[]>([])
const handleDropdownChange = (value: string) => {
// animate card height between two open menus only
setIsSwitchingDropdown(value !== '' && activeDropdown !== '')
setActiveDropdown(value)
if (value === '') return
setVisibleDropdown(value)
if (!openedDropdowns.includes(value)) setOpenedDropdowns([...openedDropdowns, value])
}
const isLoggedIn = useIsLoggedIn()
const isUserLoading = useIsUserLoading()
const user = useUser()
const menu = getMenu()
const dropdownTitles: string[] = menu.primaryNav
.filter((menuItem) => menuItem.hasDropdown)
.map((menuItem) => menuItem.title)
const getDropdownSide = (title: string) => {
if (title === visibleDropdown) return 'active'
return dropdownTitles.indexOf(title) < dropdownTitles.indexOf(visibleDropdown) ? 'start' : 'end'
}
const sendTelemetryEvent = useSendTelemetryEvent()
const userMenu = useDropdownMenu(user)
const isGAWeekSection = pathname?.startsWith('/ga-week')
const isStateOfStartupsPage = pathname?.startsWith('/state-of-startups')
const disableStickyNav = isGAWeekSection || !stickyNavbar
const showLaunchWeekNavMode = isGAWeekSection && !open
const [scrolled, setScrolled] = React.useState(false)
React.useEffect(() => {
if (!isStateOfStartupsPage) return
const handleScroll = () => setScrolled(window.scrollY > 50)
window.addEventListener('scroll', handleScroll)
return () => window.removeEventListener('scroll', handleScroll)
}, [isStateOfStartupsPage])
const isTransparent = isStateOfStartupsPage && !scrolled && !open
React.useEffect(() => {
if (open) {
// Prevent scrolling on mount
document.body.style.overflow = 'hidden'
} else {
document.body.style.overflow = 'auto'
}
}, [open])
// Close mobile menu when desktop
React.useEffect(() => {
if (width >= 1024) setOpen(false)
}, [width])
if (hideNavbar) {
return null
}
return (
<>
{!isStateOfStartupsPage && <AnnouncementBanner />}
<div
className={cn(
'sticky top-0 z-40 transform',
disableStickyNav && 'relative',
isStateOfStartupsPage && 'fixed left-0 right-0'
)}
style={{ transform: 'translate3d(0,0,999px)' }}
data-nav-transparent={isTransparent ? '' : undefined}
>
{isStateOfStartupsPage && <AnnouncementBanner />}
<div
className={cn(
'absolute inset-0 h-full w-full bg-background/90 dark:bg-background/95 transition-all duration-300',
!showLaunchWeekNavMode && !isTransparent && 'opacity-100!',
showLaunchWeekNavMode && 'bg-transparent! dark:bg-black!',
isGAWeekSection && 'dark:bg-alternative!',
isTransparent && 'bg-transparent! dark:bg-transparent! opacity-100!'
)}
/>
<nav
className={cn(
`relative z-40 border-default border-b backdrop-blur-xs transition-all duration-300`,
showLaunchWeekNavMode && 'border-muted border-b bg-transparent',
isTransparent && 'border-transparent backdrop-blur-none'
)}
>
<div className="section-container relative flex justify-between h-16">
<div className="flex items-center flex-1 sm:items-stretch justify-between">
<div className="flex items-center">
<div className="flex items-center shrink-0">
<RightClickBrandLogo />
</div>
<NavigationMenu
delayDuration={0}
value={activeDropdown}
onValueChange={handleDropdownChange}
renderViewport={false}
className="static hidden pl-8 lg:flex h-16 items-stretch"
>
<NavigationMenuList className="h-full space-x-0 items-stretch">
{menu.primaryNav.map((menuItem) =>
menuItem.hasDropdown ? (
<NavigationMenuItem
className="text-sm font-medium"
key={menuItem.title}
value={menuItem.title}
>
<NavigationMenuTrigger
className={cn(
buttonVariants({ variant: 'text', size: 'small' }),
'bg-transparent! hover:text-primary data-open:text-primary! focus-ring focus-visible:text-foreground px-2.5 h-full'
)}
>
{menuItem.title}
</NavigationMenuTrigger>
<NavigationMenuContent
forceMount
inert={visibleDropdown !== menuItem.title}
data-active={visibleDropdown === menuItem.title}
data-side={getDropdownSide(menuItem.title)}
className={cn(
'md:w-full data-[motion^=from-]:animate-none! data-[motion^=to-]:animate-none!',
'data-[active=false]:pointer-events-none data-[active=false]:opacity-0',
'data-[side=start]:-translate-x-4 data-[side=end]:translate-x-4',
'motion-safe:group-data-[switching=true]/viewport:transition-[opacity,translate]',
'motion-safe:group-data-[switching=true]/viewport:duration-250',
'motion-safe:group-data-[switching=true]/viewport:ease-in-out'
)}
>
{openedDropdowns.includes(menuItem.title) ? menuItem.dropdown : null}
</NavigationMenuContent>
</NavigationMenuItem>
) : (
<NavigationMenuItem className="text-sm font-medium" key={menuItem.title}>
<NavigationMenuLink asChild>
<MenuItem
href={menuItem.url}
title={menuItem.title}
className="group-hover:bg-transparent text-foreground focus-visible:text-primary px-2.5 h-full"
hoverColor="brand"
/>
</NavigationMenuLink>
</NavigationMenuItem>
)
)}
</NavigationMenuList>
<NavigationMenuViewport
forceMount
data-open={activeDropdown !== ''}
data-switching={isSwitchingDropdown}
containerProps={{ className: 'inset-x-0' }}
className={cn(
'group/viewport origin-top scale-100 rounded-xl bg-surface-75 md:w-[960px]',
'data-[state=open]:animate-none! data-[state=closed]:animate-none!',
'data-[state=open]:duration-200 data-[state=open]:ease-out data-[state=closed]:duration-200',
'data-[open=false]:invisible data-[open=false]:scale-[0.97] data-[open=false]:opacity-0',
'data-[open=false]:pointer-events-none',
'motion-safe:transition-[opacity,scale,visibility]',
'motion-safe:data-[switching=true]:transition-[height,opacity,scale,visibility]',
'motion-reduce:transition-none'
)}
/>
</NavigationMenu>
</div>
<div className="flex items-center gap-2 opacity-0 animate-fade-in scale-100! delay-300">
<div
className={cn(
'flex items-center gap-2 transition-opacity',
isUserLoading ? 'opacity-0' : 'opacity-100'
)}
>
<DevToolbarTrigger />
<GitHubButton />
{isLoggedIn ? (
<>
<Button className="hidden lg:inline-flex" asChild>
<Link href="/dashboard/projects">Dashboard</Link>
</Button>
<AuthenticatedDropdownMenu menu={userMenu} user={user} site="www" />
</>
) : (
<>
<Button className="hidden lg:inline-flex" asChild>
<Link
href="https://supabase.com/dashboard"
onClick={() =>
sendTelemetryEvent({
action: 'sign_in_button_clicked',
properties: { buttonLocation: 'Header Nav' },
})
}
>
Sign in
</Link>
</Button>
<Button variant="primary" className="hidden lg:inline-flex" asChild>
<Link
href="https://supabase.com/dashboard/sign-up"
onClick={() =>
sendTelemetryEvent({
action: 'start_project_button_clicked',
properties: { buttonLocation: 'Header Nav' },
})
}
>
Start your project
</Link>
</Button>
</>
)}
</div>
</div>
</div>
<HamburgerButton
toggleFlyOut={() => setOpen(true)}
showLaunchWeekNavMode={showLaunchWeekNavMode}
/>
</div>
<MobileMenu open={open} setOpen={setOpen} menu={menu} />
</nav>
<ScrollProgress />
</div>
</>
)
}
export default Nav