1
0

icon-button.tsx 837 B

123456789101112131415161718192021222324252627282930
  1. import { KnownIconType } from "@charcoal-ui/icons";
  2. import { ButtonHTMLAttributes } from "react";
  3. type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
  4. iconName: keyof KnownIconType;
  5. isProcessing: boolean;
  6. label?: string;
  7. };
  8. export const IconButton = ({
  9. iconName,
  10. isProcessing,
  11. label,
  12. ...rest
  13. }: Props) => {
  14. return (
  15. <button
  16. {...rest}
  17. className={`bg-primary hover:bg-primary-hover active:bg-primary-press disabled:bg-primary-disabled text-white rounded-lg text-sm p-1 text-center inline-flex items-center mr-2
  18. ${rest.className}
  19. `}
  20. >
  21. {isProcessing ? (
  22. <pixiv-icon name={"24/Dot"} scale="1"></pixiv-icon>
  23. ) : (
  24. <pixiv-icon name={iconName} scale="1"></pixiv-icon>
  25. )}
  26. {label && <div className="mx-2 font-bold">{label}</div>}
  27. </button>
  28. );
  29. };