From 81e0b2849d837649da9adbc5d077b8c819fe7bee Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 15 Apr 2024 18:39:59 +0100 Subject: feature: Add title to bookmarks and allow editing them. Fixes #27 --- apps/web/components/ui/action-button.tsx | 40 +++++++++++++++++++++++++------- apps/web/components/ui/button.tsx | 27 ++++++++++++++++++++- 2 files changed, 57 insertions(+), 10 deletions(-) (limited to 'apps/web/components/ui') diff --git a/apps/web/components/ui/action-button.tsx b/apps/web/components/ui/action-button.tsx index e9cdc3c9..2ac361f5 100644 --- a/apps/web/components/ui/action-button.tsx +++ b/apps/web/components/ui/action-button.tsx @@ -4,15 +4,20 @@ import { useClientConfig } from "@/lib/clientConfig"; import type { ButtonProps } from "./button"; import { Button } from "./button"; import LoadingSpinner from "./spinner"; +import { + Tooltip, + TooltipContent, + TooltipPortal, + TooltipTrigger, +} from "./tooltip"; -const ActionButton = React.forwardRef< - HTMLButtonElement, - ButtonProps & { - loading: boolean; - spinner?: React.ReactNode; - ignoreDemoMode?: boolean; - } ->( +interface ActionButtonProps extends ButtonProps { + loading: boolean; + spinner?: React.ReactNode; + ignoreDemoMode?: boolean; +} + +const ActionButton = React.forwardRef( ( { children, loading, spinner, disabled, ignoreDemoMode = false, ...props }, ref, @@ -35,4 +40,21 @@ const ActionButton = React.forwardRef< ); ActionButton.displayName = "ActionButton"; -export { ActionButton }; +const ActionButtonWithTooltip = React.forwardRef< + HTMLButtonElement, + ActionButtonProps & { tooltip: string; delayDuration?: number } +>(({ tooltip, delayDuration, ...props }, ref) => { + return ( + + + + + + {tooltip} + + + ); +}); +ActionButtonWithTooltip.displayName = "ActionButtonWithTooltip"; + +export { ActionButton, ActionButtonWithTooltip }; 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( ); Button.displayName = "Button"; -export { Button, buttonVariants }; +const ButtonWithTooltip = React.forwardRef< + HTMLButtonElement, + ButtonProps & { tooltip: string; delayDuration?: number } +>(({ tooltip, delayDuration, ...props }, ref) => { + return ( + + +