mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem Our `<Button>` component breaks the default `button` contract by redefining the `type` prop to set its variant (`primary`, `default`, etc) instead of the button type (`submit`, `button`, etc). This is confusing and forces to write more code when using it with shadcn components that expect/inject the standard button props. ## Solution - rename the `type` prop to `variant` - rename the `htmlType` prop to `type` - propagate the changes where necessary - format code ## How to test As this is just prop renaming, if it builds it's ok --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
111 lines
3.4 KiB
TypeScript
111 lines
3.4 KiB
TypeScript
'use client'
|
|
|
|
import { Calendar, MoreHorizontal, Tags, Trash, User } from 'lucide-react'
|
|
import * as React from 'react'
|
|
import {
|
|
Button,
|
|
Command,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuShortcut,
|
|
DropdownMenuSub,
|
|
DropdownMenuSubContent,
|
|
DropdownMenuSubTrigger,
|
|
DropdownMenuTrigger,
|
|
ScrollArea,
|
|
} from 'ui'
|
|
|
|
const labels = [
|
|
'feature',
|
|
'bug',
|
|
'enhancement',
|
|
'documentation',
|
|
'design',
|
|
'question',
|
|
'maintenance',
|
|
]
|
|
|
|
export default function ComboboxDropdownMenu() {
|
|
const [label, setLabel] = React.useState('feature')
|
|
const [open, setOpen] = React.useState(false)
|
|
|
|
return (
|
|
<div className="bg-surface-100 flex w-full flex-col items-start justify-between rounded-md border px-4 py-3 sm:flex-row sm:items-center">
|
|
<p className="text-sm font-medium leading-none">
|
|
<span className="mr-2 rounded-lg bg-surface-200 border px-2 py-1 text-xs text-foreground">
|
|
{label}
|
|
</span>
|
|
<span className="text-foreground">Create a new project</span>
|
|
</p>
|
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
icon={<MoreHorizontal className="text-foreground-muted" />}
|
|
></Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-[200px]">
|
|
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem>
|
|
<User className="mr-2 h-4 w-4" />
|
|
Assign to...
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem>
|
|
<Calendar className="mr-2 h-4 w-4" />
|
|
Set due date...
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuSub>
|
|
<DropdownMenuSubTrigger>
|
|
<Tags className="mr-2 h-4 w-4" />
|
|
Apply label
|
|
</DropdownMenuSubTrigger>
|
|
<DropdownMenuSubContent className="p-0">
|
|
<Command>
|
|
<CommandInput placeholder="Filter label..." autoFocus={true} />
|
|
<ScrollArea className="h-20">
|
|
<CommandList>
|
|
<CommandEmpty>No label found.</CommandEmpty>
|
|
<CommandGroup>
|
|
{labels.map((label) => (
|
|
<CommandItem
|
|
key={label}
|
|
value={label}
|
|
onSelect={(value) => {
|
|
setLabel(value)
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
{label}
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</ScrollArea>
|
|
</Command>
|
|
</DropdownMenuSubContent>
|
|
</DropdownMenuSub>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem className="text-red-600">
|
|
<Trash className="mr-2 h-4 w-4" />
|
|
Delete
|
|
<DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
)
|
|
}
|