main-site/src/lib/components/ui/button/index.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-04-04 23:55:56 +02:00
import type { Button as ButtonPrimitive } from "bits-ui";
import { type VariantProps, tv } from "tailwind-variants";
import Root from "./button.svelte";
2024-01-01 05:56:29 +01:00
const buttonVariants = tv({
2025-04-04 23:55:56 +02:00
base: "focus-visible:ring-ring inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:pointer-events-none disabled:opacity-50",
2024-01-01 05:56:29 +01:00
variants: {
variant: {
2025-04-04 23:55:56 +02:00
default: "bg-primary text-primary-foreground hover:bg-primary/90 shadow",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm",
2024-01-01 05:56:29 +01:00
outline:
2025-04-04 23:55:56 +02:00
"border-input bg-background hover:bg-accent hover:text-accent-foreground border shadow-sm",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-sm",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
2024-01-01 05:56:29 +01:00
},
size: {
2025-04-04 23:55:56 +02:00
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
2024-01-01 05:56:29 +01:00
},
defaultVariants: {
2025-04-04 23:55:56 +02:00
variant: "default",
size: "default",
},
2024-01-01 05:56:29 +01:00
});
2025-04-04 23:55:56 +02:00
type Variant = VariantProps<typeof buttonVariants>["variant"];
type Size = VariantProps<typeof buttonVariants>["size"];
2024-01-01 05:56:29 +01:00
type Props = ButtonPrimitive.Props & {
variant?: Variant;
size?: Size;
};
type Events = ButtonPrimitive.Events;
export {
Root,
type Props,
type Events,
//
Root as Button,
type Props as ButtonProps,
type Events as ButtonEvents,
2025-04-04 23:55:56 +02:00
buttonVariants,
2024-01-01 05:56:29 +01:00
};