54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
// * Packages
|
|
import { Link } from "@inertiajs/react";
|
|
import { ReactNode } from "react";
|
|
import { VariantProps } from "class-variance-authority";
|
|
// * Components shadcn
|
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from "@/components/ui/tooltip";
|
|
|
|
type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|
type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
|
type ButtonType = React.ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
|
|
type BtnTooltipProps = {
|
|
link: string;
|
|
content: ReactNode;
|
|
icon: ReactNode;
|
|
className?: string;
|
|
type?: ButtonType;
|
|
size?: ButtonSize;
|
|
variant?: ButtonVariant;
|
|
};
|
|
|
|
export default function BtnTooltip({
|
|
link,
|
|
content,
|
|
icon,
|
|
className = "",
|
|
type = "button",
|
|
size = "icon",
|
|
variant = "default",
|
|
}: BtnTooltipProps) {
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant={variant}
|
|
size={size}
|
|
className={className}
|
|
type={type}
|
|
asChild
|
|
>
|
|
<Link href={link}>{icon}</Link>
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
{content}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|