完善产品购买页面,抽取公共组件,优化导航链接

This commit is contained in:
2025-04-08 11:21:58 +08:00
parent a2c18a1be8
commit ba07c79b04
42 changed files with 1481 additions and 666 deletions

View File

@@ -3,7 +3,7 @@ import {Slot} from '@radix-ui/react-slot'
import {merge} from '@/lib/utils'
type ButtonProps = React.ComponentProps<'button'> & {
variant?: 'default' | 'outline' | 'gradient' | 'danger'
variant?: 'default' | 'outline' | 'gradient' | 'danger' | 'accent'
}
function Button(rawProps: ButtonProps) {
@@ -22,9 +22,10 @@ function Button(rawProps: ButtonProps) {
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
{
gradient: 'bg-gradient-to-r from-blue-400 to-cyan-300 text-white ring-offset-2',
default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
danger: 'bg-destructive text-white shadow-xs hover:bg-destructive/90',
outline: 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
accent: 'bg-accent text-accent-foreground hover:bg-accent/90',
danger: 'bg-destructive text-white hover:bg-destructive/90',
outline: 'border bg-background hover:bg-secondary hover:text-secondary-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
}[variant ?? 'default'],
className,
)}

View File

@@ -28,7 +28,11 @@ function Form<T extends FieldValues>(rawProps: FormProps<T>) {
return (
<FormProvider {...form}>
<form {...props} onSubmit={form.handleSubmit(onSubmit)}>
<form {...props} onSubmit={event => {
event.preventDefault()
form.handleSubmit(onSubmit)(event)
event.stopPropagation()
}}>
{children}
</form>
</FormProvider>