1
0
Fork 0
fahrPool/web/components/ui/Button.tsx

29 lines
1.1 KiB
TypeScript

import type { ComponentProps } from "react";
export type ButtonVariant = "primary" | "secondary" | "destructive";
const VARIANT_CLASSES: Record<ButtonVariant, string> = {
primary: "bg-performance-blue text-white hover:bg-night-blue",
secondary: "bg-white text-asphalt-grey border border-asphalt-grey hover:bg-aluminium-grey",
destructive: "bg-status-danger text-white hover:bg-red-700",
};
export function buttonClasses(variant: ButtonVariant = "primary", fullWidth = true): string {
return [
"inline-flex min-h-11 items-center justify-center rounded-md px-4 py-2 text-center font-medium",
"transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",
"focus-visible:outline-performance-blue disabled:cursor-not-allowed disabled:opacity-50",
VARIANT_CLASSES[variant],
fullWidth ? "w-full" : "",
].join(" ");
}
export function Button({
variant = "primary",
fullWidth = true,
className = "",
...props
}: ComponentProps<"button"> & { variant?: ButtonVariant; fullWidth?: boolean }) {
return <button className={`${buttonClasses(variant, fullWidth)} ${className}`} {...props} />;
}