Spaces:
Sleeping
Sleeping
Download Frontend/src/components/ui/Button.jsx from smit9604/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/components/ui/Button.jsx
- Command line
-
hf download hf://spaces/smit9604/ExamCraftAI/Frontend/src/components/ui/Button.jsx
-
curl -L -o Button.jsx https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/components/ui/Button.jsx
2.2 kB
| import React from "react"; | |
| import { cn } from "../../utils/cn"; | |
| import { Loader2 } from "lucide-react"; | |
| import { motion } from "framer-motion"; | |
| const buttonVariants = { | |
| primary: | |
| "bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-primary/20 hover:shadow-primary/40 active:scale-95", | |
| secondary: | |
| "bg-secondary text-secondary-foreground hover:bg-secondary/80 active:scale-95", | |
| ghost: "hover:bg-accent/10 hover:text-accent active:scale-95", | |
| danger: | |
| "bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-md shadow-destructive/20 hover:shadow-destructive/40 active:scale-95", | |
| outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground active:scale-95" | |
| }; | |
| const buttonSizes = { | |
| sm: "h-9 px-3 text-sm", | |
| md: "h-11 px-5 py-2 text-base", | |
| lg: "h-12 px-8 text-lg", | |
| icon: "h-10 w-10", | |
| }; | |
| export const Button = React.forwardRef( | |
| ( | |
| { | |
| className, | |
| variant = "primary", | |
| size = "md", | |
| isLoading = false, | |
| disabled, | |
| children, | |
| ...props | |
| }, | |
| ref | |
| ) => { | |
| return ( | |
| <motion.button | |
| ref={ref} | |
| whileTap={{ scale: disabled || isLoading ? 1 : 0.98 }} | |
| className={cn( | |
| "inline-flex items-center justify-center rounded-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 relative overflow-hidden", | |
| buttonVariants[variant], | |
| buttonSizes[size], | |
| className | |
| )} | |
| disabled={disabled || isLoading} | |
| {...props} | |
| > | |
| {isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} | |
| {children} | |
| {/* Ripple/Glow effect placeholder */} | |
| <span className="absolute inset-0 z-[-1] bg-white/10 opacity-0 hover:opacity-100 transition-opacity duration-300" /> | |
| </motion.button> | |
| ); | |
| } | |
| ); | |
| Button.displayName = "Button"; | |