-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Process): 支持Circle模式的进度条 (#2154)
* fix(Process): 支持Circle模式的进度条 * fix: 修改build错误
- Loading branch information
Ryan Zhang
authored
Jun 6, 2023
1 parent
e3106a9
commit c4335bd
Showing
5 changed files
with
142 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { usePrefixCls } from '@gio-design/utils'; | ||
import { ProgressProps } from './interface'; | ||
|
||
const sizeMapping = { | ||
large: { size: 120, border: 6 }, | ||
default: { size: 80, border: 4 }, | ||
small: { size: 20, border: 3 }, | ||
}; | ||
|
||
const ProgressCircle: React.FC<ProgressProps> = ({ | ||
percent = 0, | ||
status = 'active', | ||
format, | ||
customizePrefixCls, | ||
// animation, | ||
// className, | ||
style, | ||
size, | ||
strokeLinecap, | ||
...rest | ||
}: ProgressProps) => { | ||
const prefixCls = usePrefixCls('progress-circle', customizePrefixCls); | ||
|
||
const width = sizeMapping[size || 'default']?.size || sizeMapping.default.size; | ||
const border = sizeMapping[size || 'default']?.border || sizeMapping.default.border; | ||
|
||
const r = width / 2 - 3; | ||
const perimeter = Math.PI * r * 2; | ||
const strokeDashOffset = perimeter - (perimeter * 75) / 100; | ||
return ( | ||
<div data-testid="progress" className={`${prefixCls} ${prefixCls}-${status}`} style={style} {...rest}> | ||
<svg width={width} height={width} viewBox={`${-width / 2} ${-width / 2} ${width} ${width}`}> | ||
<circle cx="0" cy="0" r={r} fill="#fff" strokeWidth={border} stroke="#dfe4ee" strokeLinecap="round" /> | ||
<circle | ||
cx="0" | ||
cy="0" | ||
r={r} | ||
fill="#ffffff00" | ||
strokeWidth={border} | ||
className="circle" | ||
stroke="#1248e9" | ||
strokeLinecap={strokeLinecap || 'round'} | ||
strokeDasharray={`${perimeter}, ${perimeter}`} | ||
strokeDashoffset={strokeDashOffset} | ||
/> | ||
</svg> | ||
{size !== 'small' && ( | ||
<span className={`${prefixCls}-text`} style={{ width }}> | ||
{format?.(percent) || `${percent}%`} | ||
</span> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProgressCircle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c4335bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
gio-design – ./
gio-design-git-master-growingio.vercel.app
gio-design.vercel.app
gio-design-growingio.vercel.app