All files / src/components/ProgressBar/Progress index.js

0% Statements 0/14
0% Branches 0/4
100% Functions 0/0
0% Lines 0/14
1 2 3 4 5 6 7 8 9 10 11 12 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                                                                                   
/**
 * @Component Progress
 * @Type 进度条组件
 * @Author 瞿龙俊 - qulongjun@shine.design
 * @Date 2019-03-25 18:50
 */
import React, {PureComponent} from 'react';
import _ from 'lodash';
import classNames from 'classnames';
import * as PropTypes from 'prop-types';
import {classPrefix} from 'variables';
import '../style/index.scss';
 
class Progress extends PureComponent {
 
  render() {
    const {height, className, attributes, children} = this.props;
 
    const isDefaultHeight = !_.isUndefined(height) && _.includes(['small', 'large'], height);
 
    /** 计算样式 */
    const classes = classNames(
      `${classPrefix}-progress`,
      {[`${classPrefix}-progress-${height}`]: isDefaultHeight},
      className,
    );
 
    const style = !isDefaultHeight ? {height} : {};
 
    return (
      <div
        className={classes}
        style={style}
        {...attributes}
      >
        {children}
      </div>
    );
  }
}
 
Progress.propTypes = {
  /** 设置进度条粗细,支持默认值:small,large,也可以自定义高度:100px,30% 等 */
  height: PropTypes.string,
  /** 用户自定义修饰符 */
  className: PropTypes.string,
  /** 用户自定义属性 */
  attributes: PropTypes.object,
};
 
Progress.defaultProps = {
  height: undefined,
  className: '',
  attributes: {},
};
 
export default Progress;