import { CaretDownIcon } from "~/components/ui/icons/vendor"; import { Button } from "./button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "./dropdown-menu"; import { ButtonGroup } from "~/ui/components/ButtonGroup"; import { Fragment } from "react/jsx-runtime"; import { Link } from "react-router"; import { cn } from "~/lib/utils"; interface Props { children?: React.ReactNode; onClick?: () => void; href?: string; target?: string; variant?: "default" | "outline" | "ghost" | "link" | "destructive" | "secondary"; size?: "default" | "xs" | "sm" | "lg" | "icon"; items: { name: React.ReactNode; onClick?: () => void; href?: string; target?: string; main?: boolean; disabled?: boolean; className?: string; }[]; } export default function SplitButton({ items, children, onClick, href, target, variant = "outline", size = "sm" }: Props) { let foundMain = items.find((item) => item.main); return ( // Subframe ButtonGroup `variant="split"` (gap-0) is the design-system container for the // split-button pattern. `w-fit` neutralizes Subframe's `w-full`; the divider/border math // stays on the buttons themselves (rounded-*-none / border-l-0), unchanged. {foundMain?.onClick ? ( ) : foundMain?.href ? ( ) : href ? ( ) : ( )} {items.map((item, idx) => ( {item.name === "separator" ? ( ) : ( {item.href ? ( {item.name} ) : ( )} )} ))} ); }