@@ -2,13 +2,14 @@ import React, {Component, PropTypes} from 'react';
2
2
import classNames from 'classnames' ;
3
3
import $ from 'jquery' ;
4
4
import META from 'src/utils/Meta' ;
5
+ import _ from 'lodash' ;
5
6
6
7
export default class Progress extends Component {
7
8
static propTypes = {
8
9
autoSuccess : PropTypes . bool ,
9
10
children : PropTypes . node ,
10
11
className : PropTypes . string ,
11
- label : PropTypes . string ,
12
+ label : PropTypes . oneOf ( [ 'ratio' , 'percent' ] ) ,
12
13
limitValues : PropTypes . bool ,
13
14
onActive : PropTypes . func ,
14
15
onChange : PropTypes . func ,
@@ -27,8 +28,6 @@ export default class Progress extends Component {
27
28
this . element = $ ( this . refs . element ) ;
28
29
this . element . progress ( {
29
30
autoSuccess : this . props . autoSuccess ,
30
- children : this . props . children ,
31
- className : this . props . className ,
32
31
label : this . props . label ,
33
32
limitValues : this . props . limitValues ,
34
33
onActive : this . props . onActive ,
@@ -55,24 +54,28 @@ export default class Progress extends Component {
55
54
return this . element . progress ( ...arguments ) ;
56
55
}
57
56
58
- renderAttachedBar ( ) {
57
+ renderAttachedBar = ( ) => {
59
58
return (
60
59
< div className = 'bar' />
61
60
) ;
62
- }
61
+ } ;
62
+
63
+ renderStandardBar = ( ) => {
64
+ const label = (
65
+ < div className = 'label' >
66
+ { this . props . children }
67
+ </ div >
68
+ ) ;
63
69
64
- renderStandardBar ( ) {
65
70
return (
66
71
< div >
67
72
< div className = 'bar' >
68
73
< div className = 'progress' />
69
74
</ div >
70
- < div className = 'label' >
71
- { this . props . children }
72
- </ div >
75
+ { this . props . children && label }
73
76
</ div >
74
77
) ;
75
- }
78
+ } ;
76
79
77
80
render ( ) {
78
81
const classes = classNames (
@@ -82,15 +85,11 @@ export default class Progress extends Component {
82
85
'progress' ,
83
86
) ;
84
87
85
- let content = ::this . renderStandardBar ( ) ;
86
-
87
- if ( this . props . className && this . props . className . indexOf ( 'attached' ) !== - 1 ) {
88
- content = ::this . renderAttachedBar ( ) ;
89
- }
90
-
88
+ const isAttached = _ . contains ( this . props . className , 'attached' ) ;
89
+ console . log ( isAttached , classes ) ;
91
90
return (
92
91
< div { ...this . props } className = { classes } >
93
- { content }
92
+ { isAttached ? this . renderAttachedBar ( ) : this . renderStandardBar ( ) }
94
93
</ div >
95
94
) ;
96
95
}
0 commit comments