mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
improved button loading animation
This commit is contained in:
committed by
Owen Schwartz
parent
9759e86921
commit
d6e0024c96
@@ -162,3 +162,20 @@ p {
|
|||||||
#nprogress .bar {
|
#nprogress .bar {
|
||||||
background: var(--color-primary) !important;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Slot } from "@radix-ui/react-slot";
|
|||||||
import { cva, type VariantProps } from "class-variance-authority";
|
import { cva, type VariantProps } from "class-variance-authority";
|
||||||
|
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
import { Loader2 } from "lucide-react";
|
|
||||||
|
|
||||||
const buttonVariants = cva(
|
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",
|
"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<HTMLButtonElement, ButtonProps>(
|
|||||||
{asChild ? (
|
{asChild ? (
|
||||||
props.children
|
props.children
|
||||||
) : (
|
) : (
|
||||||
<>
|
<span className="relative inline-flex items-center justify-center">
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"inline-flex items-center justify-center",
|
||||||
|
loading && "opacity-0"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</span>
|
||||||
{loading && (
|
{loading && (
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
<span className="absolute inset-0 flex items-center justify-center">
|
||||||
|
<span className="flex items-center gap-1">
|
||||||
|
<span
|
||||||
|
className="h-1 w-1 bg-current animate-dot-pulse"
|
||||||
|
style={{ animationDelay: "0ms" }}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
className="h-1 w-1 bg-current animate-dot-pulse"
|
||||||
|
style={{ animationDelay: "200ms" }}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
className="h-1 w-1 bg-current animate-dot-pulse"
|
||||||
|
style={{ animationDelay: "400ms" }}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
{props.children}
|
</span>
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Comp>
|
</Comp>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user