import classNames from 'classnames' import PropTypes, { InferProps } from 'prop-types' import React from 'react' import { View, Progress } from '@tarojs/components' import { AtProgressProps } from '../../../types/progress' import AtIcon from '../icon' export default class AtProgress extends React.Component { public static defaultProps: AtProgressProps public static propTypes: InferProps get iconStatus(): 'close-circle' | 'check-circle' | 'clock' { const { status } = this.props if (status === 'error') { return 'close-circle' } if (status === 'success') { return 'check-circle' } return 'clock' } public render(): JSX.Element { const { color = '#78A4F4' } = this.props let { percent } = this.props const { strokeWidth, status, isHidePercent } = this.props if (typeof percent !== 'number') { percent = 0 } if (percent < 0) { percent = 0 } else if (percent > 100) { percent = 100 } const rootClass = classNames( 'at-progress', { [`at-progress--${status}`]: !!status, }, this.props.className, ) const iconClass = classNames('at-progress__at-icon', { 'at-progress__at-icon--error': status === 'error', 'at-progress__at-icon--success': status === 'success', }) return ( {!isHidePercent && ( {!status || status === 'progress' ? ( `${percent}%` ) : ( // )} )} ) } } AtProgress.defaultProps = { color: '#78A4F4', } AtProgress.propTypes = { color: PropTypes.string, status: PropTypes.string, percent: PropTypes.number, strokeWidth: PropTypes.number, isHidePercent: PropTypes.bool, }