aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/ui/button.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-04-15 18:39:59 +0100
committerMohamedBassem <me@mbassem.com>2024-04-15 18:55:34 +0100
commit81e0b2849d837649da9adbc5d077b8c819fe7bee (patch)
tree003bb21413372825dc19c07a87bdbe6692e384a9 /apps/web/components/ui/button.tsx
parent5c9acb1cb3bfe341378b91bbed344dd7202a00d7 (diff)
downloadkarakeep-81e0b2849d837649da9adbc5d077b8c819fe7bee.tar.zst
feature: Add title to bookmarks and allow editing them. Fixes #27
Diffstat (limited to 'apps/web/components/ui/button.tsx')
-rw-r--r--apps/web/components/ui/button.tsx27
1 files changed, 26 insertions, 1 deletions
diff --git a/apps/web/components/ui/button.tsx b/apps/web/components/ui/button.tsx
index 40794eb2..2d6dee6b 100644
--- a/apps/web/components/ui/button.tsx
+++ b/apps/web/components/ui/button.tsx
@@ -4,6 +4,13 @@ import { cn } from "@/lib/utils";
import { Slot } from "@radix-ui/react-slot";
import { cva } from "class-variance-authority";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipPortal,
+ TooltipTrigger,
+} from "./tooltip";
+
const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
@@ -24,6 +31,7 @@ const buttonVariants = cva(
link: "text-primary underline-offset-4 hover:underline",
},
size: {
+ none: "",
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
@@ -57,4 +65,21 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
);
Button.displayName = "Button";
-export { Button, buttonVariants };
+const ButtonWithTooltip = React.forwardRef<
+ HTMLButtonElement,
+ ButtonProps & { tooltip: string; delayDuration?: number }
+>(({ tooltip, delayDuration, ...props }, ref) => {
+ return (
+ <Tooltip delayDuration={delayDuration}>
+ <TooltipTrigger>
+ <Button ref={ref} {...props} />
+ </TooltipTrigger>
+ <TooltipPortal>
+ <TooltipContent>{tooltip}</TooltipContent>
+ </TooltipPortal>
+ </Tooltip>
+ );
+});
+ButtonWithTooltip.displayName = "ButtonWithTooltip";
+
+export { Button, buttonVariants, ButtonWithTooltip };