import type { PolymorphicProps } from "@kobalte/core/polymorphic";
import type { VariantProps } from "class-variance-authority";
import type { JSX, ValidComponent } from "solid-js";
import { splitProps } from "solid-js";
import * as ButtonPrimitive from "@kobalte/core/button";
import { cva } from "class-variance-authority";
import { cn } from "~/lib/utils";
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 rounded-base text-sm font-base whitespace-nowrap ring-offset-white transition-all focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
"border-2 border-border bg-primary text-primary-foreground shadow-shadow active:translate-x-box-shadow-x active:translate-y-box-shadow-y active:shadow-none",
"border-2 border-border bg-transparent text-foreground shadow-shadow active:translate-x-box-shadow-x active:translate-y-box-shadow-y active:shadow-none",
"border-2 border-border bg-transparent text-foreground hover:bg-secondary-background/50",
"bg-transparent text-foreground hover:bg-secondary-background/50",
"border-2 border-border bg-primary text-primary-foreground hover:bg-primary/80",
"border-2 border-black bg-secondary-background text-foreground shadow-destructive active:translate-x-box-shadow-x active:translate-y-box-shadow-y active:shadow-none",
"border-2 border-border bg-secondary-background text-foreground hover:bg-secondary-background/80",
"border-2 border-border bg-primary text-primary-foreground active:translate-x-reverse-box-shadow-x active:translate-y-reverse-box-shadow-y active:shadow-shadow",
link: "text-foreground underline-offset-4 hover:underline",
"border-2 border-success-foreground bg-success text-success-foreground hover:bg-success/50",
info: "border-2 border-info-foreground bg-info text-info-foreground hover:bg-info/50",
"border-2 border-warning-foreground bg-warning text-warning-foreground hover:bg-warning/50",
"border-2 border-error-foreground bg-error text-error-foreground hover:bg-error/50",
default: "h-10 px-4 py-2",
xl: "h-12 px-10 text-lg",
type ButtonProps<T extends ValidComponent = "button"> =
ButtonPrimitive.ButtonRootProps<T> &
VariantProps<typeof buttonVariants> & {
class?: string | undefined;
const Button = <T extends ValidComponent = "button">(
props: PolymorphicProps<T, ButtonProps<T>>,
const [local, others] = splitProps(props as ButtonProps, [
buttonVariants({ variant: local.variant, size: local.size }),
export { Button, buttonVariants };
export type { ButtonProps };