mirror of
https://github.com/kevinsqi/react-circular-progressbar.git
synced 2026-01-18 15:55:06 +00:00
don't render <text> if textForPercentage is falsy or returns falsy
fix #24
This commit is contained in:
parent
df50365929
commit
1d7d84cc7b
@ -74,12 +74,15 @@ class CircularProgressbar extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const classForPercentage = this.props.classForPercentage ? this.props.classForPercentage(this.props.percentage) : '';
|
||||
const {percentage, classForPercentage, textForPercentage, className, strokeWidth} = this.props
|
||||
const classForPercentage = classForPercentage ? classForPercentage(percentage) : '';
|
||||
const pathDescription = this.getPathDescription();
|
||||
|
||||
const text = textForPercentage ? textForPercentage(percentage) : null
|
||||
|
||||
return (
|
||||
<svg
|
||||
className={`CircularProgressbar ${this.props.className} ${classForPercentage}`}
|
||||
className={`CircularProgressbar ${className} ${classForPercentage}`}
|
||||
viewBox="0 0 100 100"
|
||||
>
|
||||
{
|
||||
@ -96,25 +99,25 @@ class CircularProgressbar extends React.Component {
|
||||
<path
|
||||
className="CircularProgressbar-trail"
|
||||
d={pathDescription}
|
||||
strokeWidth={this.props.strokeWidth}
|
||||
strokeWidth={strokeWidth}
|
||||
fillOpacity={0}
|
||||
/>
|
||||
|
||||
<path
|
||||
className="CircularProgressbar-path"
|
||||
d={pathDescription}
|
||||
strokeWidth={this.props.strokeWidth}
|
||||
strokeWidth={strokeWidth}
|
||||
fillOpacity={0}
|
||||
style={this.getProgressStyle()}
|
||||
/>
|
||||
|
||||
<text
|
||||
{text ? <text
|
||||
className="CircularProgressbar-text"
|
||||
x={50}
|
||||
y={50}
|
||||
>
|
||||
{this.props.textForPercentage(this.props.percentage)}
|
||||
</text>
|
||||
{text}
|
||||
</text> : null}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user