Spaces:
Paused
Paused
feat(design-system): implement absolute inversion principle, typographic audits, waitlist interactive features & WCAG 2.1 compliance
d8804ab Download components/ui/shimmer-button.tsx from samirhosninet/HubAPI: direct link, hf CLI and curl.
- Browser
- Download file 2.84 kB
-
https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/ui/shimmer-button.tsx
- Command line
-
hf download hf://spaces/samirhosninet/HubAPI/components/ui/shimmer-button.tsx
-
curl -L -o shimmer-button.tsx https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/ui/shimmer-button.tsx
2.84 kB
| import React, { type ComponentPropsWithoutRef, type CSSProperties } from "react" | |
| import { cn } from "@/lib/utils" | |
| export interface ShimmerButtonProps extends ComponentPropsWithoutRef<"button"> { | |
| shimmerColor?: string | |
| shimmerSize?: string | |
| borderRadius?: string | |
| shimmerDuration?: string | |
| background?: string | |
| className?: string | |
| children?: React.ReactNode | |
| } | |
| export const ShimmerButton = React.forwardRef< | |
| HTMLButtonElement, | |
| ShimmerButtonProps | |
| >( | |
| ( | |
| { | |
| shimmerColor = "var(--button-shimmer)", | |
| shimmerSize = "0.05em", | |
| shimmerDuration = "3s", | |
| borderRadius = "100px", | |
| background = "var(--button-bg)", | |
| className, | |
| children, | |
| ...props | |
| }, | |
| ref | |
| ) => { | |
| return ( | |
| <button | |
| style={ | |
| { | |
| "--spread": "90deg", | |
| "--shimmer-color": shimmerColor, | |
| "--radius": borderRadius, | |
| "--speed": shimmerDuration, | |
| "--cut": shimmerSize, | |
| "--bg": background, | |
| } as CSSProperties | |
| } | |
| className={cn( | |
| "group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border border-[var(--button-border)] px-6 py-3 whitespace-nowrap text-[var(--button-text)] [background:var(--bg)]", | |
| "transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px", | |
| className | |
| )} | |
| ref={ref} | |
| {...props} | |
| > | |
| {/* spark container */} | |
| <div | |
| className={cn( | |
| "-z-30 blur-[2px]", | |
| "@container-[size] absolute inset-0 overflow-visible" | |
| )} | |
| > | |
| {/* spark */} | |
| <div className="animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none [mask:none]"> | |
| {/* spark before */} | |
| <div className="animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]" /> | |
| </div> | |
| </div> | |
| {children} | |
| {/* Highlight */} | |
| <div | |
| className={cn( | |
| "absolute inset-0 size-full", | |
| "rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_var(--primary-glow)]", | |
| "transform-gpu transition-all duration-300 ease-in-out", | |
| "group-hover:shadow-[inset_0_-6px_10px_var(--primary-glow)]", | |
| "group-active:shadow-[inset_0_-10px_10px_var(--primary-glow)]" | |
| )} | |
| /> | |
| {/* backdrop */} | |
| <div | |
| className={cn( | |
| "absolute inset-(--cut) -z-20 [border-radius:var(--radius)] [background:var(--bg)]" | |
| )} | |
| /> | |
| </button> | |
| ) | |
| } | |
| ) | |
| ShimmerButton.displayName = "ShimmerButton" | |