import React, { MouseEventHandler, useMemo, ReactElement } from "react"; import useThrottle from "../../customHooks/useThrottle"; export type ButtonProps = { onClick: MouseEventHandler; text: string | React.ReactElement; className?: string; disabled?: boolean; loading?: boolean; type: "Primary" | "Secondary" | "Positive" | "Negative" | "Neutral"; customBackgroundColor?: string; icon?: string | React.ReactElement; throttleTime?: number; tooltip?: string | React.ReactElement; }; export default function Button({ onClick, text, className, disabled = false, loading = false, type, customBackgroundColor, icon, throttleTime = 300, tooltip, }: ButtonProps): ReactElement { const baseClassName = useMemo(() => { switch (type) { case "Primary": return "text-white bg-interactive-primary-default hover:bg-interactive-primary-hover active:bg-interactive-primary-pressed disabled:text-neutral-medium-light disabled:bg-neutral-light rounded-lg"; case "Secondary": return "text-interactive-primary-default bg-interactive-secondary-default hover:bg-interactive-secondary-hover active:bg-interactive-secondary-pressed disabled:text-neutral-medium-light disabled:bg-neutral-light rounded-lg"; case "Positive": return "text-white bg-semantic-ok hover:bg-interactive-ok-hover active:bg-interactive-ok-pressed disabled:text-neutral-medium-light disabled:bg-neutral-light rounded-lg"; case "Negative": return "text-white bg-semantic-alarm hover:bg-interactive-alarm-hover active:bg-interactive-alarm-pressed disabled:text-neutral-medium-light disabled:bg-neutral-light rounded-lg"; case "Neutral": return "text-neutral-medium-dark bg-neutral-very-light hover:bg-neutral-light active:bg-neutral-medium-light rounded-lg"; } }, [type]); const throttledClick = useThrottle(onClick, throttleTime); return ( ); }