mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
8d15b9e7de
* chore: format all files in the project * fix: removing @types/react from dependencies * fix: adding prettier and eslint config * chore: format files * fix: upgrading turbo version * chore: ignoring warnings and adding todos * fix: updated the type of bubble menu item in the document editor * chore: format files --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import * as React from "react";
|
|
|
|
import { getIconStyling, getButtonStyling, TButtonVariant, TButtonSizes } from "./helper";
|
|
|
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: TButtonVariant;
|
|
size?: TButtonSizes;
|
|
className?: string;
|
|
loading?: boolean;
|
|
disabled?: boolean;
|
|
appendIcon?: any;
|
|
prependIcon?: any;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
const {
|
|
variant = "primary",
|
|
size = "md",
|
|
className = "",
|
|
type = "button",
|
|
loading = false,
|
|
disabled = false,
|
|
prependIcon = null,
|
|
appendIcon = null,
|
|
children,
|
|
...rest
|
|
} = props;
|
|
|
|
const buttonStyle = getButtonStyling(variant, size, disabled || loading);
|
|
const buttonIconStyle = getIconStyling(size);
|
|
|
|
return (
|
|
<button ref={ref} type={type} className={`${buttonStyle} ${className}`} disabled={disabled || loading} {...rest}>
|
|
{prependIcon && <div className={buttonIconStyle}>{React.cloneElement(prependIcon, { strokeWidth: 2 })}</div>}
|
|
{children}
|
|
{appendIcon && <div className={buttonIconStyle}>{React.cloneElement(appendIcon, { strokeWidth: 2 })}</div>}
|
|
</button>
|
|
);
|
|
});
|
|
|
|
Button.displayName = "plane-ui-button";
|
|
|
|
export { Button };
|