Files
Danny White 476d4a5851 refactor(ui): drop redundant Button variant="default" props (#50161)
## What kind of change does this PR introduce?

Mechanical cleanup on top of the Button default-variant change (#50160).

## What is the current behavior?

Many callsites still pass `variant="default"` even though that is now
the component default.

## What is the new behavior?

Removes redundant static `variant="default"` from legacy `Button` and
`ButtonTooltip` callsites. Keeps explicit defaults where they document
the API:

- `button-default.tsx` and `button-sizes.tsx` demos
- `DocsButton`, which pins neutral styling at the wrapper boundary

## To test

Studio:

- [Auth → Rate
Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits):
dirty the form so Cancel appears; Cancel stays neutral, Save stays green
- [Project Settings → API
Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys):
`DocsButton` in the header actions stays neutral

Design system:

- [Design system →
Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button):
`button-default` / `button-sizes` still show explicit default styling;
Primary (green) is restricted to the Primary section (and `asChild`)

WWW:

- [www → Brand
assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets):
Download logo kit / Download button kit stay neutral
2026-09-11 17:05:26 +10:00

143 lines
4.5 KiB
TypeScript

import { Loader2, Search } from 'lucide-react'
import { ComponentPropsWithoutRef, forwardRef, useMemo, useState } from 'react'
import {
Button,
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
Popover,
PopoverContent,
PopoverTrigger,
ScrollArea,
} from 'ui'
import { useInfiniteTablesQuery } from '@/data/tables/tables-query'
import { useDebouncedValue } from '@/hooks/misc/useDebouncedValue'
import type { SafePostgresTable } from '@/lib/postgres-types'
type FindTableSelectorProps = Omit<ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
projectRef?: string
connectionString?: string | null
schema?: string
disabled?: boolean
size?: 'tiny' | 'small'
open: boolean
onOpenChange: (open: boolean) => void
onSelect: (table: SafePostgresTable) => void
}
export const FindTableSelector = forwardRef<HTMLDivElement, FindTableSelectorProps>(
(
{
className,
projectRef,
connectionString,
schema,
disabled = false,
size = 'tiny',
open,
onOpenChange,
onSelect,
...rest
},
ref
) => {
const [search, setSearch] = useState('')
const debouncedSearch = useDebouncedValue(search, 300)
const nameFilter = debouncedSearch.trim() || undefined
const { data, isFetching, hasNextPage, isFetchingNextPage, fetchNextPage } =
useInfiniteTablesQuery(
{
projectRef,
connectionString,
schema,
includeColumns: false,
pageSize: 50,
nameFilter,
},
{ enabled: open }
)
const tables = useMemo(() => data?.pages.flat() ?? [], [data])
const handleOpenChange = (next: boolean) => {
if (!next) setSearch('')
onOpenChange(next)
}
return (
<div ref={ref} className={className} {...rest}>
<Popover open={open} onOpenChange={handleOpenChange} modal={false}>
<PopoverTrigger asChild>
<Button
size={size}
disabled={disabled}
data-testid="find-table-selector"
icon={<Search size={14} strokeWidth={1.5} className="text-foreground-muted" />}
>
<span className="text-foreground-lighter">Find table…</span>
</Button>
</PopoverTrigger>
<PopoverContent className="p-0 w-[260px] pointer-events-auto" side="bottom" align="start">
<Command shouldFilter={false}>
<CommandInput
className="text-xs"
placeholder="Find table…"
value={search}
onValueChange={setSearch}
/>
<CommandList>
{isFetching && tables.length === 0 ? (
<div className="flex items-center justify-center gap-x-2 py-6 text-xs text-foreground-light">
<Loader2 className="animate-spin" size={14} />
<span>Loading tables</span>
</div>
) : (
<>
<CommandEmpty>No tables found</CommandEmpty>
<CommandGroup>
<ScrollArea className={tables.length > 7 ? 'h-[210px]' : ''}>
{tables.map((table) => (
<CommandItem
key={table.id}
value={String(table.id)}
className="cursor-pointer flex items-center justify-between space-x-2 w-full"
onSelect={() => {
onSelect(table)
handleOpenChange(false)
}}
>
<span>{table.name}</span>
</CommandItem>
))}
{hasNextPage && (
<div className="px-2 py-1.5">
<Button
block
size="tiny"
loading={isFetchingNextPage}
onClick={() => fetchNextPage()}
>
Load more
</Button>
</div>
)}
</ScrollArea>
</CommandGroup>
</>
)}
</CommandList>
</Command>
</PopoverContent>
</Popover>
</div>
)
}
)
FindTableSelector.displayName = 'FindTableSelector'