Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions src/Circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,27 @@ const getCircleStyle = (
};
};

const Circle: React.FC<ProgressProps> = ({
id,
prefixCls,
steps,
strokeWidth,
trailWidth,
gapDegree = 0,
gapPosition,
trailColor,
strokeLinecap,
style,
className,
strokeColor,
percent,
...restProps
}) => {
const Circle: React.FC<ProgressProps> = (props) => {
const {
id,
prefixCls,
steps,
strokeWidth,
trailWidth,
gapDegree = 0,
gapPosition,
trailColor,
strokeLinecap,
style,
className,
strokeColor,
percent,
...restProps
} = {
...defaultProps,
...props,
};

const mergedId = useId(id);
const gradientId = `${mergedId}-gradient`;
const radius = VIEW_BOX_SIZE / 2 - strokeWidth / 2;
Expand Down Expand Up @@ -233,8 +238,8 @@ const Circle: React.FC<ProgressProps> = ({
);
};

Circle.defaultProps = defaultProps;

Circle.displayName = 'Circle';
if (process.env.NODE_ENV !== 'production') {
Circle.displayName = 'Circle';
}

export default Circle;
37 changes: 21 additions & 16 deletions src/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import classNames from 'classnames';
import { useTransitionDuration, defaultProps } from './common';
import type { ProgressProps } from './interface';

const Line: React.FC<ProgressProps> = ({
className,
percent,
prefixCls,
strokeColor,
strokeLinecap,
strokeWidth,
style,
trailColor,
trailWidth,
transition,
...restProps
}) => {
const Line: React.FC<ProgressProps> = (props) => {
const {
className,
percent,
prefixCls,
strokeColor,
strokeLinecap,
strokeWidth,
style,
trailColor,
trailWidth,
transition,
...restProps
} = {
...defaultProps,
...props,
};

// eslint-disable-next-line no-param-reassign
delete restProps.gapPosition;
const percentList = Array.isArray(percent) ? percent : [percent];
Expand Down Expand Up @@ -92,8 +97,8 @@ const Line: React.FC<ProgressProps> = ({
);
};

Line.defaultProps = defaultProps;

Line.displayName = 'Line';
if (process.env.NODE_ENV !== 'production') {
Line.displayName = 'Line';
}

export default Line;
2 changes: 0 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { useRef, useEffect } from 'react';
import type { ProgressProps } from './interface';

export const defaultProps: Partial<ProgressProps> = {
className: '',
percent: 0,
prefixCls: 'rc-progress',
strokeColor: '#2db7f5',
strokeLinecap: 'round',
strokeWidth: 1,
style: {},
trailColor: '#D9D9D9',
trailWidth: 1,
gapPosition: 'bottom',
Expand Down