A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
import type { VariantProps } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
import { Slot } from "@radix-ui/react-slot";
import { cva } from "class-variance-authority";
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 dark:aria-[invalid=true]:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
{
variants: {
variant: {
none: "",
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
destructiveOutline:
"border border-destructive bg-transparent text-destructive hover:bg-destructive/90 hover:text-destructive-foreground dark:hover:bg-destructive/60",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground focus-visible:ring-0 dark:hover:bg-accent/50",
ghostDestructive:
"text-destructive hover:bg-destructive/10 hover:text-destructive focus-visible:ring-0 dark:hover:bg-destructive/20",
border: "border border-input hover:bg-accent",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
none: "",
default: "h-10 px-4 py-2 has-[>svg]:px-3",
sm: "h-9 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
lg: "h-11 rounded-md px-8 has-[>svg]:px-6",
icon: "size-10",
"icon-sm": "size-8",
"icon-xs": "size-6",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
);
export interface ButtonProps
extends
React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
},
);
Button.displayName = "Button";
export { Button, buttonVariants };