mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem The Button guidance explains split buttons but doesn't show how to group a visible action with other actions for the same item or section. ## Solution Document when to use each pattern: - **Split button:** the main button runs the most common variation of an action. The attached chevron opens alternatives, such as other export formats. - **Dropdown button:** the whole button opens a menu, such as a time-range picker. - **Button with more actions:** keep the main action visible and use a separate ellipsis menu for distinct actions. The examples show both a primary “Add pipeline” button and a default “Stop” button. Align the Admonition split-button example with the same guidance. ## Review instructions 1. Open the [Button guidance preview](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#split-with-dropdown) and compare the attached export chevron with the single time-range dropdown. 2. Open each ellipsis in [Button with more actions](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#button-with-more-actions). Check that the “Add pipeline” menu groups usage and settings separately from “Disable Pipelines”, and that the “Stop” menu separates restart from edit and delete.
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import { CircleStop, Edit, EllipsisVertical, Plus, RotateCcw, Trash } from 'lucide-react'
|
|
import type { ReactNode } from 'react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
|
|
function MoreActions({ label, children }: { label: string; children: ReactNode }) {
|
|
return (
|
|
<DropdownMenu>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
className="w-6.5"
|
|
icon={<EllipsisVertical />}
|
|
aria-label={label}
|
|
aria-describedby={undefined}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
</TooltipTrigger>
|
|
<TooltipContent>More actions</TooltipContent>
|
|
</Tooltip>
|
|
<DropdownMenuContent align="end" className="w-40">
|
|
{children}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|
|
|
|
export default function ButtonMoreActionsDemo() {
|
|
return (
|
|
<TooltipProvider>
|
|
<div className="flex flex-wrap items-center gap-10">
|
|
<div className="flex items-center gap-2">
|
|
<MoreActions label="More pipeline list actions">
|
|
<DropdownMenuItem>Pipelines usage</DropdownMenuItem>
|
|
<DropdownMenuItem>Pipelines settings</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem>Disable Pipelines</DropdownMenuItem>
|
|
</MoreActions>
|
|
<Button type="button" variant="primary" icon={<Plus />}>
|
|
Add pipeline
|
|
</Button>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
<Button type="button" icon={<CircleStop />}>
|
|
Stop
|
|
</Button>
|
|
<MoreActions label="More actions for this pipeline">
|
|
<DropdownMenuItem className="gap-x-2">
|
|
<RotateCcw size={14} aria-hidden="true" />
|
|
Restart pipeline
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem className="gap-x-2">
|
|
<Edit size={14} aria-hidden="true" />
|
|
Edit pipeline
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="gap-x-2">
|
|
<Trash size={14} aria-hidden="true" />
|
|
Delete pipeline
|
|
</DropdownMenuItem>
|
|
</MoreActions>
|
|
</div>
|
|
</div>
|
|
</TooltipProvider>
|
|
)
|
|
}
|