mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 15:33:22 +00:00
37 lines
865 B
JavaScript
37 lines
865 B
JavaScript
import React from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
|
|
const Button = ({
|
|
text,
|
|
onClick,
|
|
href,
|
|
className,
|
|
primary,
|
|
icon,
|
|
disabled,
|
|
}) => {
|
|
const router = useRouter();
|
|
const baseClass =
|
|
'px-4 py-2 rounded-md text-white h-8 flex items-center justify-center';
|
|
const primaryClass = 'bg-emerald-500 hover:bg-emerald-600';
|
|
const secondaryClass = 'bg-gray-300 hover:bg-gray-400 text-black';
|
|
const buttonClass = `${baseClass} ${primary && !disabled ? primaryClass : secondaryClass} ${className}`;
|
|
|
|
const handleClick = (e) => {
|
|
if (href) {
|
|
router.push(href);
|
|
} else if (onClick) {
|
|
onClick(e);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<button className={buttonClass} onClick={handleClick} disabled={disabled}>
|
|
{icon && <span className="mr-2">{icon}</span>}
|
|
{text}
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default Button;
|