import React, { Component } from 'react';
import IceLoading from '@ali/ice-loading';
import '@ali/ice-loading/lib/style';

export default class Loading extends Component {
  shouldComponentUpdate() {
    return false;
  }

  render() {
    const { size, text } = this.props;
    const fontSize = size === 'small' ? 12 : 16;
    return (
      <div title="loading">
        <div style={{ padding: '100px 0px', textAlign: 'center' }}>
          <IceLoading
            color="#2477fa"
            size="large"
            type="square-spin"
            style={{ margin: '0 auto' }}
          />
          <p
            style={{
              color: '#999',
              fontSize: `${fontSize}px`,
              marginTop: '15px',
            }}
          >
            {text || '加载中，请稍后'}
          </p>
        </div>
      </div>
    );
  }
}
