ButtonDiy.js 1.4 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10 11 12
/**
 * 钟是志
 * 2019年1月10日
 * 一个Button
 */

import React, { Component, Fragment } from 'react';
import { Button, Icon } from 'antd';
import styles from './index.less';
import PropTypes from 'prop-types';

export default class ButtonDiy extends Component {
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
	render() {
		const {
			handleClick,
			icon,
			name,
			className,
			type,
			htmlType,
			loading,
			disabled,
			size,
			style,
			boxStyle,
		} = this.props;
		return (
			<span className={styles.ButtonDiy} style={{ ...boxStyle }}>
				<Button
					onClick={() => {
						handleClick();
					}}
					loading={loading}
					className={styles[className]}
					style={{ ...style }}
					type={type}
					disabled={disabled}
					htmlType={htmlType}>
					{icon ? <Icon type={icon} /> : null}
					{name}
				</Button>
			</span>
		);
	}
徐立's avatar
徐立 committed
45 46
}
ButtonDiy.propTypes = {
47 48 49 50 51 52 53 54
	name: PropTypes.string,
	icon: PropTypes.string, // icon
	handleClick: PropTypes.func, // click函数
	className: PropTypes.string, // classname
	type: PropTypes.string, // Button type
	htmlType: PropTypes.string,
	disabled: PropTypes.bool,
	loading: PropTypes.bool, //
徐立's avatar
徐立 committed
55 56
};
ButtonDiy.defaultProps = {
57 58 59 60 61 62 63
	icon: '', //'plus'
	name: '新建子部门',
	disabled: false,
	type: 'primary',
	htmlType: 'button',
	loading: false,
	className: '', // primaryBlue = {背景色,边框:蓝色 字体:白色} defaultBlue= {背景色:白色 字体,边框:蓝色} defaultRed = {背景色:白色 字体,边框:红色}
徐立's avatar
徐立 committed
64

65
	handleClick: () => {},
徐立's avatar
徐立 committed
66
};