mirror of
https://github.com/kevinsqi/react-circular-progressbar.git
synced 2026-01-18 15:55:06 +00:00
WIP on making colors configurably change depending on percentage
This commit is contained in:
parent
3e1c7d5fb3
commit
df1cd98a22
@ -40,7 +40,7 @@ class ChangingProgressbar extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
return <CircularProgressbar percentage={this.state.percentage} />;
|
||||
return <CircularProgressbar {...this.props} percentage={this.state.percentage} />;
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +60,10 @@ 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">
|
||||
<ChangingProgressbar />
|
||||
|
||||
<ChangingProgressbar
|
||||
classForPercentage={(percentage) => (percentage < 50 ? 'low' : 'high')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ class CircularProgressbar extends React.Component {
|
||||
|
||||
return (
|
||||
<svg
|
||||
className="CircularProgressbar"
|
||||
className={`CircularProgressbar ${this.props.classForPercentage ? this.props.classForPercentage(this.percentage) : ''}`}
|
||||
viewBox="0 0 100 100"
|
||||
>
|
||||
<path
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
.CircularProgressbar .CircularProgressbar-path {
|
||||
stroke: #3c3;
|
||||
stroke: #3e98c7;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.5s ease 0s;
|
||||
}
|
||||
@ -15,7 +15,21 @@
|
||||
}
|
||||
|
||||
.CircularProgressbar .CircularProgressbar-text {
|
||||
fill: #3e98c7;
|
||||
font-size: 20px;
|
||||
dominant-baseline: middle;
|
||||
text-anchor: middle;
|
||||
}
|
||||
|
||||
.CircularProgressbar.low .CircularProgressbar-path {
|
||||
stroke: #00f;
|
||||
}
|
||||
.CircularProgressbar.low .CircularProgressbar-text {
|
||||
fill: #00f;
|
||||
}
|
||||
.CircularProgressbar.low .CircularProgressbar-path {
|
||||
stroke: #f00;
|
||||
}
|
||||
.CircularProgressbar.high .CircularProgressbar-text {
|
||||
fill: #f00;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user