Skip to content

Commit a5f9693

Browse files
committed
remove the error demos
1 parent 342a009 commit a5f9693

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default () => (
140140
<td>dot</td>
141141
<td>Boolean | Object</td>
142142
<td>false</td>
143-
<td>within dot or not, value: true, false, { size: Number }</td>
143+
<td>within dot or not, value: true, false, { size: Number }, if the size is not a number, it will be the strokeWidth as default</td>
144144
</tr>
145145
</tbody>
146146
</table>

docs/examples/gap.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Example extends React.Component<ProgressProps, any> {
4141
Change State [{percent}]
4242
</button>
4343
</p>
44+
<h3>within dot</h3>
4445
<div style={circleContainerStyle}>
4546
<Circle
4647
percent={percent}
@@ -65,6 +66,7 @@ class Example extends React.Component<ProgressProps, any> {
6566
/>
6667
</div>
6768

69+
<h3>without dot</h3>
6870
<div style={circleContainerStyle}>
6971
<Circle
7072
percent={percent}
@@ -73,7 +75,6 @@ class Example extends React.Component<ProgressProps, any> {
7375
strokeWidth={6}
7476
strokeLinecap="square"
7577
strokeColor={color}
76-
dot={{ size: 'p' }}
7778
/>
7879
</div>
7980
<div style={circleContainerStyle}>
@@ -84,7 +85,6 @@ class Example extends React.Component<ProgressProps, any> {
8485
strokeWidth={6}
8586
strokeLinecap="square"
8687
strokeColor={color}
87-
dot={{ size: [] }}
8888
/>
8989
</div>
9090
</div>

docs/examples/gradient-circle.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Example = () => {
1010

1111
return (
1212
<div>
13-
<h3>Circle Progress {90}%</h3>
13+
<h3>Circle Progress {90}% (within dot)</h3>
1414
<div style={circleContainerStyle}>
1515
<Circle
1616
percent={90}
@@ -20,7 +20,7 @@ const Example = () => {
2020
'0%': '#108ee9',
2121
'100%': '#87d068',
2222
}}
23-
dot={{ size: '10' }}
23+
dot={true}
2424
/>
2525
</div>
2626
<h3>Circle Progress {100}%</h3>
@@ -33,7 +33,6 @@ const Example = () => {
3333
'100%': '#108ee9',
3434
'0%': '#87d068',
3535
}}
36-
dot={{}}
3736
/>
3837
</div>
3938
<h3>Circle With Success Percent {65}%</h3>

src/Circle.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,18 @@ const Circle: React.FC<ProgressProps> = ({
115115

116116
path.setAttribute('d', pathDom.props.d);
117117
const dotPoint = path.getPointAtLength(strokeLength);
118+
118119
return (
119120
<circle
120121
key={index + 10}
121122
className={`${prefixCls}-circle-dot`}
122123
cx={dotPoint.x}
123124
cy={dotPoint.y}
124-
r={typeof dot === 'object' ? dot.size : strokeWidth}
125+
r={
126+
typeof dot === 'object' && dot.size && typeof dot.size === 'number'
127+
? dot.size
128+
: strokeWidth
129+
}
125130
fill={pathDom.props.stroke ? pathDom.props.stroke : pathDom.props.style.stroke}
126131
/>
127132
);

tests/index.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,28 @@ describe('Progress', () => {
156156
);
157157
});
158158
});
159+
160+
describe('dot', () => {
161+
it('the size of dot must be a number', () => {
162+
const wrapper = mount(
163+
<Circle percent={30} gapDegree={70} dot={{ size: '10' }} strokeWidth="6" />,
164+
);
165+
expect(wrapper.find('.rc-progress-circle-dot').getDOMNode().r).toBe(
166+
wrapper.find('.rc-progress-circle-path').getDOMNode().strokeWidth,
167+
);
168+
169+
wrapper.setProps({ dot: { size: 10 } });
170+
expect(wrapper.find('.rc-progress-circle-dot').getDOMNode().r).toBe('10');
171+
172+
wrapper.setProps({ dot: true });
173+
expect(wrapper.find('.rc-progress-circle-dot').getDOMNode().r).toBe(
174+
wrapper.find('.rc-progress-circle-path').getDOMNode().strokeWidth,
175+
);
176+
177+
wrapper.setProps({ dot: [] });
178+
expect(wrapper.find('.rc-progress-circle-dot').getDOMNode().r).toBe(
179+
wrapper.find('.rc-progress-circle-path').getDOMNode().strokeWidth,
180+
);
181+
});
182+
});
159183
});

0 commit comments

Comments
 (0)