index.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use client";
  2. import clsx from "clsx";
  3. import { CSSProperties, FC, PropsWithChildren } from "react";
  4. import styles from "./style.module.scss";
  5. /**
  6. * @description 自定义button按钮
  7. * @param {any} children 插槽内容
  8. * @param {boolean} active 是否高亮
  9. * @param {() => void} callbackFun 回调方法
  10. */
  11. export interface ButtonOwnProps {
  12. children?: any;
  13. active?: boolean;
  14. callbackFun?: () => void;
  15. className?: string;
  16. style?: CSSProperties;
  17. [props: string]: any;
  18. }
  19. const ButtonOwn: FC<PropsWithChildren<ButtonOwnProps>> = ({
  20. children = "",
  21. active = false,
  22. deposit = false,
  23. callbackFun,
  24. className,
  25. style,
  26. ...other
  27. }) => {
  28. const divClassName = clsx(
  29. {
  30. [styles.button]: true,
  31. [styles.active]: active,
  32. [styles.deposit]: deposit,
  33. },
  34. className
  35. );
  36. return (
  37. <button
  38. style={style}
  39. className={divClassName}
  40. {...other}
  41. onClick={() => (active || deposit) && callbackFun && callbackFun()}
  42. >
  43. {children}
  44. </button>
  45. );
  46. };
  47. export default ButtonOwn;