type ButtonProps = {
    onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
    as?: 'a' | 'button'; // 要渲染成什麼元素
    disabled?: boolean;
    type?: string;
    buttonType?: 'submit' | 'reset' | 'button' | undefined;
    label?: string;
    iconButton?: boolean;
    icon?: string;
};

export default function Button({
    onClick,
    as = 'button',
    type = '',
    buttonType = undefined,
    label = 'Button',
    iconButton = false,
    icon = 'arrowRight',
}: ButtonProps) {
    const buttonInner = iconButton ? <i className={icon}></i> : <span className="button-text">{label}</span>;
    if (as === 'a') {
        return (
            <a href="#" className={`button ${type}`}>
                {buttonInner}
            </a>
        );
    } else {
        return (
            <button type={buttonType} className={`button ${type}`} onClick={onClick}>
                {buttonInner}
            </button>
        );
    }
}
