index.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import BaseButton, { ButtonProps as BaseButtonProps } from './Button';
  3. import IconButton, { IconButtonProps } from '../iconButton';
  4. export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
  5. export { HorizontalPaddingType } from '../iconButton';
  6. export { ButtonGroupProps } from './buttonGroup';
  7. export { SplitButtonGroupProps } from './splitButtonGroup';
  8. // eslint-disable-next-line
  9. export interface ButtonProps extends IconButtonProps {} // TODO check
  10. class Button extends React.PureComponent<ButtonProps> {
  11. static propTypes = {
  12. ...BaseButton.propTypes,
  13. ...IconButton.propTypes,
  14. };
  15. constructor(props = {}) {
  16. super(props);
  17. }
  18. render() {
  19. const props = { ...this.props };
  20. const hasIcon = Boolean(props.icon);
  21. const isLoading = Boolean(props.loading);
  22. const isDisabled = Boolean(props.disabled);
  23. if (hasIcon || (isLoading && !isDisabled)) {
  24. return <IconButton {...props} />;
  25. } else {
  26. return <BaseButton {...props} />;
  27. }
  28. }
  29. }
  30. export default Button;