38 lines
812 B
TypeScript
38 lines
812 B
TypeScript
"use client"
|
|
|
|
import { Slot } from "@radix-ui/react-slot"
|
|
import { Button as ButtonRAC } from "react-aria-components"
|
|
|
|
import { buttonVariants } from "./variants"
|
|
|
|
import type { ButtonProps } from "./button"
|
|
|
|
export default function Button(props: ButtonProps) {
|
|
const { className, intent, size, theme, wrapping, variant, ...restProps } =
|
|
props
|
|
|
|
const classNames = buttonVariants({
|
|
className,
|
|
intent,
|
|
size,
|
|
theme,
|
|
wrapping,
|
|
variant,
|
|
})
|
|
|
|
if (restProps.asChild) {
|
|
const { asChild, ...slotProps } = restProps
|
|
return <Slot className={classNames} {...slotProps} />
|
|
}
|
|
|
|
const { asChild, onClick, disabled, ...racProps } = restProps
|
|
return (
|
|
<ButtonRAC
|
|
className={classNames}
|
|
isDisabled={disabled}
|
|
onPress={onClick}
|
|
{...racProps}
|
|
/>
|
|
)
|
|
}
|