Skip to content

Commit fdd2d48

Browse files
committed
update per review
1 parent d799baa commit fdd2d48

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

src/modules/Progress/Progress.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import React, {Component, PropTypes} from 'react';
22
import classNames from 'classnames';
33
import $ from 'jquery';
44
import META from 'src/utils/Meta';
5+
import _ from 'lodash';
56

67
export default class Progress extends Component {
78
static propTypes = {
89
autoSuccess: PropTypes.bool,
910
children: PropTypes.node,
1011
className: PropTypes.string,
11-
label: PropTypes.string,
12+
label: PropTypes.oneOf(['ratio', 'percent']),
1213
limitValues: PropTypes.bool,
1314
onActive: PropTypes.func,
1415
onChange: PropTypes.func,
@@ -27,8 +28,6 @@ export default class Progress extends Component {
2728
this.element = $(this.refs.element);
2829
this.element.progress({
2930
autoSuccess: this.props.autoSuccess,
30-
children: this.props.children,
31-
className: this.props.className,
3231
label: this.props.label,
3332
limitValues: this.props.limitValues,
3433
onActive: this.props.onActive,
@@ -55,24 +54,28 @@ export default class Progress extends Component {
5554
return this.element.progress(...arguments);
5655
}
5756

58-
renderAttachedBar() {
57+
renderAttachedBar = () => {
5958
return (
6059
<div className='bar' />
6160
);
62-
}
61+
};
62+
63+
renderStandardBar = () => {
64+
const label = (
65+
<div className='label'>
66+
{this.props.children}
67+
</div>
68+
);
6369

64-
renderStandardBar() {
6570
return (
6671
<div>
6772
<div className='bar'>
6873
<div className='progress'/>
6974
</div>
70-
<div className='label'>
71-
{this.props.children}
72-
</div>
75+
{this.props.children && label}
7376
</div>
7477
);
75-
}
78+
};
7679

7780
render() {
7881
const classes = classNames(
@@ -82,15 +85,11 @@ export default class Progress extends Component {
8285
'progress',
8386
);
8487

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);
9190
return (
9291
<div {...this.props} className={classes}>
93-
{content}
92+
{isAttached ? this.renderAttachedBar() : this.renderStandardBar()}
9493
</div>
9594
);
9695
}
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {Progress} from 'stardust';
33

4-
describe('Progress', () => {
4+
describe.only('Progress', () => {
55
it('should be able to receive children', () => {
66
render(
77
<Progress>
@@ -14,10 +14,15 @@ describe('Progress', () => {
1414
render(<Progress />).findClass('bar');
1515
});
1616

17-
// it('should create a div with the class of progress', () => {
18-
// const bugger = render(<Progress />);
19-
// console.log(bugger);
20-
// debugger;
21-
// render(<Progress />).scryClass('progress');
22-
// });
17+
it('should create two progress divs if un-attached', () => {
18+
render(<Progress />)
19+
.scryClass('progress')
20+
.should.have.a.lengthOf(2);
21+
});
22+
23+
it('should not create extra progress div if attached', () => {
24+
render(<Progress className='attached' />)
25+
.scryClass('progress')
26+
.should.have.a.lengthOf(1);
27+
});
2328
});

0 commit comments

Comments
 (0)