/**
 * Created by ZN on 2018/5/03.
 */
import React, {Component} from 'react';
/*import PropTypes from 'prop-types';*/
import style from './index.less';

/**
 * Button组件
 *可配置属性:
 * type: 默认（即不配置type,蓝色实心70*30），normal(蓝边空心70*30),warning（橙色100%40）,model（蓝色实心80*30）
 * disabled:
 * onClick:
 * 示例：<Button disabled><Icon type='confirm' />确定</Button>
 * **/
/*const propTypes = {
    icon: PropTypes.oneOf(['confirm','close','add','aptmts','cancel','print','qa','search','setting','update','tick','submit','more','info']),
    onClick: PropTypes.func
};*/

class Button extends Component {
    constructor(props) {
        super(props);
        /* this.handleClick = this.handleClick.bind(this);
         this.handleLeave = this.handleLeave.bind(this);*/
    }

    /*handleClick(){
        this.props.onClick&&this.props.onClick();
    }*/

    render() {
        let props = this.props;
        let type = props.type ? style[props.type] : '';
        let classes = style["button"] + " " + type;
        const spanStyle = {
            position: "relative",
            left: "-3px",
            lineHeight: "30px"
        };
        if (props.disabled) {
            return <button contenteditable="false" className={classes} style={props.style}  {...props} disabled>
                {
                    React.Children.map(props.children, function (child) {
                        return <span style={spanStyle}>{child}</span>;
                    })
                }
            </button>;
        }
        return <button contenteditable="false" className={classes} style={props.style} {...props}>
            {
                React.Children.map(props.children, function (child) {
                    return <span style={spanStyle}>{child}</span>;
                })
            }
        </button>;
    }
}
/*Button.propTypes = propTypes;*/

export default Button;