Button.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { ButtonHTMLAttributes, ReactNode } from 'react';
  2. interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  3. variant?: 'primary' | 'secondary' | 'danger' | 'ghost';
  4. size?: 'sm' | 'md' | 'lg';
  5. children: ReactNode;
  6. }
  7. export function Button({
  8. variant = 'primary',
  9. size = 'md',
  10. className = '',
  11. children,
  12. ...props
  13. }: ButtonProps) {
  14. const baseStyles =
  15. 'inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed';
  16. const variants = {
  17. primary: 'bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green',
  18. secondary:
  19. 'bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray',
  20. danger: 'bg-red-600 hover:bg-red-700 text-white focus:ring-red-500',
  21. ghost:
  22. 'bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white',
  23. };
  24. const sizes = {
  25. sm: 'px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0',
  26. md: 'px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0',
  27. lg: 'px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0',
  28. };
  29. return (
  30. <button
  31. className={`${baseStyles} ${variants[variant]} ${sizes[size]} ${className}`}
  32. {...props}
  33. >
  34. {children}
  35. </button>
  36. );
  37. }