mirror of
https://github.com/kevinsqi/react-circular-progressbar.git
synced 2026-01-18 15:55:06 +00:00
Add colored path, wip on animation
This commit is contained in:
parent
6221540564
commit
9b2b526f8f
@ -35,7 +35,7 @@ class Demo extends React.Component {
|
||||
|
||||
<div className="row m-b-3">
|
||||
<div className="col-xs-6 offset-xs-3 col-md-2 offset-md-5">
|
||||
<CircularProgressbar />
|
||||
<CircularProgressbar percentage={50} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -12,16 +12,33 @@ class CircularProgressbar extends React.Component {
|
||||
a ${radius},${radius} 0 1 1 0,${2 * radius}
|
||||
a ${radius},${radius} 0 1 1 0,-${2 * radius}
|
||||
`;
|
||||
|
||||
const diameter = Math.PI * 2 * radius;
|
||||
const progressStyle = {
|
||||
strokeDasharray: `${diameter}px ${diameter}px`,
|
||||
strokeDashoffset: `${((100 - this.props.percentage) / 100 * diameter)}px`,
|
||||
};
|
||||
|
||||
return (
|
||||
<svg
|
||||
className="CircularProgressbar"
|
||||
viewBox="0 0 100 100"
|
||||
>
|
||||
<path
|
||||
className="CircularProgressbar-trail"
|
||||
d={pathDescription}
|
||||
strokeWidth={this.props.strokeWidth}
|
||||
fillOpacity="0"
|
||||
fillOpacity={0}
|
||||
/>
|
||||
|
||||
<path
|
||||
className="CircularProgressbar-path"
|
||||
d={pathDescription}
|
||||
strokeWidth={this.props.strokeWidth}
|
||||
fillOpacity={0}
|
||||
style={progressStyle}
|
||||
/>
|
||||
|
||||
<text>Hello</text>
|
||||
</svg>
|
||||
);
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
* All of the styles in this file are optional and configurable!
|
||||
*/
|
||||
|
||||
.CircularProgressbar path {
|
||||
stroke: #ccc;
|
||||
.CircularProgressbar .CircularProgressbar-path {
|
||||
stroke: #3c3;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease;
|
||||
}
|
||||
|
||||
.CircularProgressbar .CircularProgressbar-trail {
|
||||
stroke: #d6d6d6;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user