Skip to content

Commit

Permalink
Refactor label rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Dec 26, 2018
1 parent f33dc4e commit 80cd670
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/components/progressbar/ProgressBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
height: 100%;
width: 100%;
position: absolute;
display: none;
font-weight: bold;
}

Expand Down
14 changes: 13 additions & 1 deletion src/components/progressbar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,25 @@ export class ProgressBar extends Component {
return this.props.value !== nextProps.value;
}

renderLabel() {
if (this.props.showValue && this.props.value) {
return (
<div className="p-progressbar-label">{this.props.value + this.props.unit}</div>
);
}
else {
return null;
}
}

renderDeterminate() {
let className = classNames('p-progressbar p-component p-progressbar-determinate', this.props.className);
let label = this.renderLabel();

return (
<div role="progressbar" id={this.props.id} className={className} style={this.props.style} aria-valuemin="0" aria-valuenow={this.props.value} aria-valuemax="100" aria-label={this.props.value}>
<div className="p-progressbar-value p-progressbar-value-animate" style={{width: this.props.value + '%', display: 'block'}}></div>
{this.props.showValue && <div className="p-progressbar-label" style={{display: this.props.value ? 'block' : 'none'}}>{this.props.value + this.props.unit}</div>}
{label}
</div>
);
}
Expand Down

0 comments on commit 80cd670

Please sign in to comment.