55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { forwardRef, type ButtonHTMLAttributes } from "react";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
interface ShimmerButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
shimmerColor?: string;
|
|
background?: string;
|
|
className?: string;
|
|
}
|
|
|
|
export const ShimmerButton = forwardRef<HTMLButtonElement, ShimmerButtonProps>(
|
|
(
|
|
{
|
|
shimmerColor = "rgba(201,169,110,0.55)",
|
|
background = "var(--color-moy-dark)",
|
|
className,
|
|
children,
|
|
...props
|
|
},
|
|
ref
|
|
) => (
|
|
<button
|
|
ref={ref}
|
|
className={cn(
|
|
"group relative inline-flex items-center justify-center overflow-hidden",
|
|
"px-10 py-4 text-[11px] font-medium uppercase tracking-[0.2em] text-white",
|
|
"transition-all duration-300",
|
|
className
|
|
)}
|
|
style={{ background }}
|
|
{...props}
|
|
>
|
|
{/* Animated shimmer strip */}
|
|
<span
|
|
aria-hidden
|
|
className="pointer-events-none absolute inset-0"
|
|
style={{
|
|
background: `linear-gradient(105deg, transparent 35%, ${shimmerColor} 50%, transparent 65%)`,
|
|
backgroundSize: "200% 100%",
|
|
animation: "shimmer 2.8s linear infinite",
|
|
}}
|
|
/>
|
|
{/* Inset bg to sit above shimmer */}
|
|
<span
|
|
aria-hidden
|
|
className="absolute inset-[1px]"
|
|
style={{ background }}
|
|
/>
|
|
<span className="relative">{children}</span>
|
|
</button>
|
|
)
|
|
);
|
|
ShimmerButton.displayName = "ShimmerButton";
|