Files
novalon-website/src/components/ui/button.tsx
T
张翔 522f1e09a7 feat: 重构网站UI设计并优化布局结构
重构整体UI设计,采用红色主题配色方案
优化页面布局结构,将Header和Footer移至page组件
更新按钮样式和交互效果,增强视觉反馈
调整全局字体配置,使用思源黑体作为中文字体
改进各区块卡片样式,增加悬停动画效果
优化响应式设计,提升移动端体验
2026-02-08 16:46:22 +08:00

65 lines
2.1 KiB
TypeScript

import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all duration-200 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/50",
{
variants: {
variant: {
default: "bg-[#C41E3A] text-white hover:bg-[#A01830] hover:shadow-lg hover:shadow-[#C41E3A]/25 hover:-translate-y-0.5",
destructive:
"bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-500/50",
outline:
"border-2 border-[#C41E3A] bg-transparent text-[#C41E3A] hover:bg-[#FEF2F4] hover:text-[#A01830]",
secondary:
"bg-[#FAF8F8] text-[#1A1A1A] hover:bg-[#F5F0F0]",
ghost:
"hover:bg-[#F5F0F0] hover:text-[#1A1A1A]",
link: "text-[#C41E3A] underline-offset-4 hover:underline hover:text-[#A01830]",
},
size: {
default: "h-10 px-6 py-2",
xs: "h-7 gap-1 rounded-md px-2 text-xs [&_svg:not([class*='size-'])]:size-3",
sm: "h-8 rounded-md gap-1.5 px-4",
lg: "h-12 rounded-md px-8 text-base",
icon: "size-10",
"icon-xs": "size-7 rounded-md [&_svg:not([class*='size-'])]:size-3",
"icon-sm": "size-8",
"icon-lg": "size-12",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
variant = "default",
size = "default",
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot : "button"
return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
}
export { Button, buttonVariants }