CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.
TypeScript ai-agentsai-diagramai-presentationbomcadcanvasdiagramdiagram-generatordrawioflowchartinfographicspptppt-generatorpresentation-generatorreactsvgedittext-to-diagramtypescriptworkflow
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/shared/lib/utils"
const buttonVariants = cva(
[
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium",
"transition-[background-color,border-color,color,box-shadow,transform,opacity] duration-fast ease-out-soft",
// The press has to undershoot the rest position, otherwise a click on a
// lifted button reads as nothing happening. `active:` sorts after `hover:`
// so it wins while the pointer is down.
"active:translate-y-px",
"disabled:pointer-events-none disabled:opacity-50",
"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0",
"outline-none focus-visible:border-ring focus-visible:ring-ring/35 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
],
{
variants: {
variant: {
// Disabled goes neutral rather than half-transparent: a 50%-opacity
// clay block read as a broken or loading button, not an unavailable one.
default:
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90 hover:shadow-soft hover:-translate-y-px disabled:bg-muted disabled:text-muted-foreground disabled:shadow-none disabled:opacity-100",
destructive:
"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 hover:-translate-y-px focus-visible:ring-destructive/30",
outline:
"border border-border bg-card text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground hover:-translate-y-px hover:shadow-soft",
secondary:
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/70 hover:-translate-y-px",
ghost:
"hover:bg-accent hover:text-accent-foreground",
link:
"text-primary-strong underline-offset-4 hover:underline active:translate-y-0",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
lg: "h-11 rounded-lg px-6 text-[15px] has-[>svg]:px-4",
icon: "size-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
const Button = React.forwardRef<
HTMLButtonElement,
React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}
>(({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
ref={ref}
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
})
Button.displayName = "Button"
export { Button, buttonVariants }