Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ React.render(<div>
<td>#D9D9D9</td>
<td> Color for lighter trail stroke underneath the actual progress path.</td>
</tr>
<tr>
<td>strokeLinecap</td>
<td>String</td>
<td>round</td>
<td> The shape to be used at the end of the progress bar, can be square or round.</td>
</tr>
</tbody>
</table>

Expand Down
6 changes: 3 additions & 3 deletions examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ const Example = React.createClass({
<div>
<h3>Line Progress {this.state.percent}%</h3>
<div style={containerStyle}>
<Line percent={this.state.percent} strokeWidth="4" strokeColor={this.state.color} />
<Line percent={this.state.percent} strokeWidth="4" strokeColor={this.state.color}/>
</div>
<h3>Circle Progress {this.state.percent}%</h3>
<div style={circleContainerStyle}>
<Circle percent={this.state.percent} strokeWidth="6" strokeColor={this.state.color} />
<Circle percent={this.state.percent} strokeWidth="6" strokeLinecap="square" strokeColor={this.state.color}/>
</div>
<p>
<button onClick={this.changeState}>Change State</button>
</p>
</div>
);
);
},
});

Expand Down
6 changes: 4 additions & 2 deletions src/Line.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ const Line = React.createClass({
const right = (100 - strokeWidth / 2);
const pathString = `M ${center},${center} L ${right},${center}`;
const viewBoxString = `0 0 100 ${strokeWidth}`;
const linecap = props.strokeLinecap || 'round';


return (
<svg className="rc-progress-line" viewBox={viewBoxString} preserveAspectRatio="none">
<path className="rc-progress-line-trail" d={pathString} strokeLinecap="round"
<path className="rc-progress-line-trail" d={pathString} strokeLinecap={linecap}
stroke={props.trailColor} strokeWidth={props.trailWidth} fillOpacity="0"/>

<path className="rc-progress-line-path" d={pathString} strokeLinecap="round"
<path className="rc-progress-line-path" d={pathString} strokeLinecap={linecap}
stroke={props.strokeColor} strokeWidth={props.strokeWidth} fillOpacity="0" style={pathStyle}/>
</svg>
);
Expand Down
4 changes: 3 additions & 1 deletion src/Progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const Circle = React.createClass({
'strokeDashoffset': `${((100 - props.percent) / 100 * len)}px`,
'transition': 'stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease',
};
const linecap = props.strokeLinecap || 'round';

['strokeWidth', 'strokeColor', 'trailWidth', 'trailColor'].forEach((item) => {
if (item === 'trailWidth' && !props.trailWidth && props.strokeWidth) {
props.trailWidth = props.strokeWidth;
Expand All @@ -32,7 +34,7 @@ const Circle = React.createClass({
<path className="rc-progress-circle-trail" d={pathString} stroke={props.trailColor}
strokeWidth={props.trailWidth} fillOpacity="0"/>

<path className="rc-progress-circle-path" d={pathString} strokeLinecap="round"
<path className="rc-progress-circle-path" d={pathString} strokeLinecap={linecap}
stroke={props.strokeColor} strokeWidth={props.strokeWidth} fillOpacity="0" style={pathStyle}/>
</svg>
);
Expand Down