rqbit/crates/librqbit/webui/src/components/buttons/IconButton.tsx

31 lines
715 B
TypeScript
Raw Normal View History

import { MouseEventHandler } from "react";
export const IconButton: React.FC<{
onClick: () => void;
disabled?: boolean;
className?: string;
color?: string;
children: any;
}> = (props) => {
const { onClick, disabled, color, children, className, ...otherProps } =
props;
const onClickStopPropagation: MouseEventHandler<HTMLAnchorElement> = (e) => {
e.stopPropagation();
if (disabled) {
return;
}
onClick();
};
const colorClassName = color ? `text-${color}` : "";
return (
<a
2023-12-17 10:34:35 +00:00
className={`block p-1 text-blue-500 ${colorClassName} ${className}`}
onClick={onClickStopPropagation}
href="#"
{...otherProps}
>
{children}
</a>
);
};