mirror of
https://github.com/OwethuManagedServices/oms-website-nextjs.git
synced 2025-12-17 15:38:09 +00:00
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
// components/ui/Button.tsx
|
|
import React from "react";
|
|
import Link from "next/link";
|
|
|
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
href?: string;
|
|
variant?: "primary" | "secondary" | "outline" | "ghost" | "destructive"; // Added more variants
|
|
size?: "sm" | "md" | "lg";
|
|
children: React.ReactNode;
|
|
className?: string;
|
|
}
|
|
|
|
const Button: React.FC<ButtonProps> = ({
|
|
href,
|
|
variant = "primary",
|
|
size = "md",
|
|
children,
|
|
className = "",
|
|
...props
|
|
}) => {
|
|
// Base styles including focus ring using semantic vars
|
|
const baseStyle =
|
|
"inline-flex items-center justify-center rounded-lg font-semibold transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background cursor-pointer disabled:pointer-events-none disabled:opacity-50 text-sm";
|
|
|
|
// Variant styles using semantic vars (Tailwind classes generated via @theme)
|
|
const variantStyles = {
|
|
primary: "bg-primary text-primary-foreground hover:bg-primary/90", // bg-primary generated from --primary
|
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
outline:
|
|
"border border-border bg-transparent hover:bg-accent hover:text-accent-foreground",
|
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
destructive:
|
|
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
};
|
|
|
|
const sizeStyles = {
|
|
sm: "px-3 py-1.5 text-sm",
|
|
md: "px-4 py-2 text-base",
|
|
lg: "px-6 py-3 text-lg",
|
|
};
|
|
|
|
const combinedClassName = `${baseStyle} ${variantStyles[variant]} ${sizeStyles[size]} ${className}`;
|
|
|
|
if (href) {
|
|
return (
|
|
<Link href={href} className={combinedClassName}>
|
|
{children}
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<button type="button" className={combinedClassName} {...props}>
|
|
{children}
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default Button;
|