button.tsx 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import * as React from "react";
  2. import styles from "./button.module.scss";
  3. export function IconButton(props: {
  4. onClick?: () => void;
  5. icon?: JSX.Element;
  6. type?: "primary" | "danger";
  7. text?: string;
  8. bordered?: boolean;
  9. shadow?: boolean;
  10. className?: string;
  11. title?: string;
  12. disabled?: boolean;
  13. }) {
  14. return (
  15. <button
  16. className={
  17. styles["icon-button"] +
  18. ` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
  19. props.className ?? ""
  20. } clickable ${styles[props.type ?? ""]}`
  21. }
  22. onClick={props.onClick}
  23. title={props.title}
  24. disabled={props.disabled}
  25. role="button"
  26. >
  27. {props.icon && (
  28. <div
  29. className={
  30. styles["icon-button-icon"] +
  31. ` ${props.type === "primary" && "no-dark"}`
  32. }
  33. >
  34. {props.icon}
  35. </div>
  36. )}
  37. {props.text && (
  38. <div className={styles["icon-button-text"]}>{props.text}</div>
  39. )}
  40. </button>
  41. );
  42. }