UNPKG

plot-plan-designer

Version:

Design Editor Tools with React.js + ant.design + fabric.js

44 lines (43 loc) 2.74 kB
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Tooltip, Button } from 'antd'; import Icon from '../icon/Icon'; class CommonButton extends Component { render() { return this.props.visible ? (React.createElement(Tooltip, { title: this.props.tooltipTitle, placement: this.props.tooltipPlacement }, this.props.wrapperClassName || this.props.wrapperStyle ? (React.createElement("span", { style: this.props.wrapperStyle, className: this.props.wrapperClassName }, React.createElement(Button, { id: this.props.id, className: this.props.className, name: this.props.name, style: this.props.style, shape: this.props.shape, size: this.props.size, onClick: this.props.onClick, type: this.props.type, disabled: this.props.disabled, loading: this.props.loading }, this.props.icon ? (this.props.iconAnimation ? (React.createElement(Icon, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName, animation: this.props.iconAnimation })) : (React.createElement(Icon, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName }))) : null, this.props.children))) : (React.createElement(Button, { id: this.props.id, className: this.props.className, name: this.props.name, style: this.props.style, shape: this.props.shape, size: this.props.size, onClick: this.props.onClick, type: this.props.type, disabled: this.props.disabled, loading: this.props.loading }, this.props.icon ? (this.props.iconAnimation ? (React.createElement(Icon, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName, animation: this.props.iconAnimation })) : (React.createElement(Icon, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName }))) : null, this.props.children)))) : null; } } CommonButton.propTypes = { name: PropTypes.string, id: PropTypes.string, style: PropTypes.object, wrapperStyle: PropTypes.object, wrapperClassName: PropTypes.string, tooltipTitle: PropTypes.string, tooltipPlacement: PropTypes.string, className: PropTypes.string, icon: PropTypes.string, iconStyle: PropTypes.object, iconClassName: PropTypes.string, iconAnimation: PropTypes.string, visible: PropTypes.bool, shape: PropTypes.string, disabled: PropTypes.bool, loading: PropTypes.bool, type: PropTypes.string, size: PropTypes.oneOf(['small', 'middle', 'large']), onClick: PropTypes.func, children: PropTypes.node, }; CommonButton.defaultProps = { type: 'default', visible: true, disabled: false, loading: false, }; export default CommonButton;