import {
	Spin
} from 'antd';

export default class CenterSpin extends React.Component {
	render() {
		const {
			loading,
			size,
		} = this.props;

		const style = {
			position: 'absolute',
			top: '50%',
			left: '50%',
			marginLeft: -8,
			marginTop: -8,
		}

		if (size === 'large') {
			Object.assign(style, {
				marginLeft: -16,
				marginTop: -16,
			});
		}

		if (loading) {
			return (
				<div style={style}>
					<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@zb5hfv`} spinning={true} size={size}></Spin>
				</div>
			)
		}else{
			return this.props.children
		}


	}
}