From d6e0024c961777884de6be298b65ebd6dde60dc7 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Tue, 23 Dec 2025 12:51:38 -0500 Subject: [PATCH] improved button loading animation --- src/app/globals.css | 17 +++++++++++++++++ src/components/ui/button.tsx | 31 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index bd5860a6..70c614c0 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -162,3 +162,20 @@ p { #nprogress .bar { background: var(--color-primary) !important; } + +@keyframes dot-pulse { + 0%, 80%, 100% { + opacity: 0.3; + transform: scale(0.8); + } + 40% { + opacity: 1; + transform: scale(1); + } +} + +@layer utilities { + .animate-dot-pulse { + animation: dot-pulse 1.4s ease-in-out infinite; + } +} diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index f530ace1..9f32e9ce 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -3,7 +3,6 @@ import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@app/lib/cn"; -import { Loader2 } from "lucide-react"; const buttonVariants = cva( "cursor-pointer inline-flex items-center justify-center whitespace-nowrap 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-0 disabled:pointer-events-none disabled:opacity-50", @@ -75,12 +74,34 @@ const Button = React.forwardRef( {asChild ? ( props.children ) : ( - <> + + + {props.children} + {loading && ( - + + + + + + + )} - {props.children} - + )} );