Skip to content

refactor: all use rail #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ export default () => (
<td>Stroke color.</td>
</tr>
<tr>
<td>trailWidth</td>
<td>railWidth</td>
<td>Number</td>
<td>1</td>
<td>Width of the trail stroke. Unit is percentage of SVG canvas size. Trail is always centered relative to actual progress path. If trailWidth is not defined, it is the same as strokeWidth.</td>
<td>Width of the rail stroke. Unit is percentage of SVG canvas size. Rail is always centered relative to actual progress path. If railWidth is not defined, it is the same as strokeWidth.</td>
</tr>
<tr>
<td>trailColor</td>
<td>railColor</td>
<td>String</td>
<td>#D9D9D9</td>
<td>Color for lighter trail stroke underneath the actual progress path.</td>
<td>Color for lighter rail stroke underneath the actual progress path.</td>
</tr>
<tr>
<td>strokeLinecap</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/gap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Example extends React.Component<ProgressProps, any> {
gapDegree={70}
gapPosition="bottom"
strokeWidth={6}
trailWidth={6}
railWidth={6}
strokeLinecap="round"
strokeColor={multiPercentageStrokeColors}
/>
Expand Down
14 changes: 7 additions & 7 deletions src/Circle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const Circle: React.FC<ProgressProps> = (props) => {
styles = {},
steps,
strokeWidth,
trailWidth,
railWidth,
gapDegree = 0,
gapPosition,
trailColor,
railColor,
strokeLinecap,
style,
className,
Expand Down Expand Up @@ -68,7 +68,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
rotateDeg,
gapDegree,
gapPosition,
trailColor,
railColor,
mergedStrokeLinecap,
strokeWidth,
);
Expand Down Expand Up @@ -129,7 +129,7 @@ const Circle: React.FC<ProgressProps> = (props) => {

let stackPtg = 0;
return new Array(stepCount).fill(null).map<React.ReactNode>((_, index) => {
const color = index <= current - 1 ? strokeColorList[0] : trailColor;
const color = index <= current - 1 ? strokeColorList[0] : railColor;
const stroke = color && typeof color === 'object' ? `url(#${gradientId})` : undefined;
const circleStyleForStack = getCircleStyle(
perimeter,
Expand Down Expand Up @@ -181,13 +181,13 @@ const Circle: React.FC<ProgressProps> = (props) => {
>
{!stepCount && (
<circle
className={cls(`${prefixCls}-circle-trail`, classNames.rail)}
className={cls(`${prefixCls}-circle-rail`, classNames.rail)}
r={radius}
cx={halfSize}
cy={halfSize}
stroke={trailColor}
stroke={railColor}
strokeLinecap={mergedStrokeLinecap}
strokeWidth={trailWidth || strokeWidth}
strokeWidth={railWidth || strokeWidth}
style={{
...circleStyle,
...styles.rail,
Expand Down
10 changes: 5 additions & 5 deletions src/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const Line: React.FC<ProgressProps> = (props) => {
strokeLinecap,
strokeWidth,
style,
trailColor,
trailWidth,
railColor,
railWidth,
transition,
loading,
...restProps
Expand Down Expand Up @@ -57,11 +57,11 @@ const Line: React.FC<ProgressProps> = (props) => {
{...restProps}
>
<path
className={`${prefixCls}-line-trail`}
className={`${prefixCls}-line-rail`}
d={pathString}
strokeLinecap={strokeLinecap}
stroke={trailColor}
strokeWidth={trailWidth || strokeWidth}
stroke={railColor}
strokeWidth={railWidth || strokeWidth}
fillOpacity="0"
/>
{percentList.map((ptg, index) => {
Expand Down
4 changes: 2 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const defaultProps: Partial<ProgressProps> = {
strokeColor: '#2db7f5',
strokeLinecap: 'round',
strokeWidth: 1,
trailColor: '#D9D9D9',
trailWidth: 1,
railColor: '#D9D9D9',
railWidth: 1,
gapPosition: 'bottom',
loading: false,
};
Expand Down
4 changes: 2 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export type SemanticName = 'root' | 'rail' | 'track';
export interface ProgressProps {
id?: string;
strokeWidth?: number;
trailWidth?: number;
railWidth?: number;
className?: string;
classNames?: Partial<Record<SemanticName, string>>;
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
percent?: number | number[];
strokeColor?: StrokeColorType;
trailColor?: string;
railColor?: string;
strokeLinecap?: StrokeLinecapType;
prefixCls?: string;
style?: React.CSSProperties;
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/conic.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Circle.conic gapDegree 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand Down Expand Up @@ -59,7 +59,7 @@ exports[`Circle.conic should work 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand Down
34 changes: 17 additions & 17 deletions tests/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`Progress Circle change with animation 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="49.5"
Expand Down Expand Up @@ -36,7 +36,7 @@ exports[`Progress Circle change with animation 2`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="49.5"
Expand Down Expand Up @@ -66,7 +66,7 @@ exports[`Progress Circle should gradient works and circles have different gradie
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand Down Expand Up @@ -112,7 +112,7 @@ exports[`Progress Circle should gradient works and circles have different gradie
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand Down Expand Up @@ -163,7 +163,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand All @@ -189,7 +189,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand All @@ -215,7 +215,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand All @@ -241,7 +241,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand All @@ -267,7 +267,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand All @@ -293,7 +293,7 @@ exports[`Progress Circle should show right gapPosition 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="47"
Expand Down Expand Up @@ -324,7 +324,7 @@ exports[`Progress Diff Line should match snapshot 1`] = `
viewBox="0 0 100 1"
>
<path
class="rc-progress-line-trail"
class="rc-progress-line-rail"
d="M 0,0.5
L 100,0.5"
fill-opacity="0"
Expand All @@ -350,7 +350,7 @@ exports[`Progress Diff Line should match snapshot 1`] = `
viewBox="0 0 100 1"
>
<path
class="rc-progress-line-trail"
class="rc-progress-line-rail"
d="M 0.5,0.5
L 99.5,0.5"
fill-opacity="0"
Expand All @@ -376,7 +376,7 @@ exports[`Progress Diff Line should match snapshot 1`] = `
viewBox="0 0 100 1"
>
<path
class="rc-progress-line-trail"
class="rc-progress-line-rail"
d="M 0,0.5
L 100,0.5"
fill-opacity="0"
Expand Down Expand Up @@ -405,7 +405,7 @@ exports[`Progress Line change with animation 1`] = `
viewBox="0 0 100 1"
>
<path
class="rc-progress-line-trail"
class="rc-progress-line-rail"
d="M 0.5,0.5
L 99.5,0.5"
fill-opacity="0"
Expand Down Expand Up @@ -433,7 +433,7 @@ exports[`Progress Line change with animation 2`] = `
viewBox="0 0 100 1"
>
<path
class="rc-progress-line-trail"
class="rc-progress-line-rail"
d="M 0.5,0.5
L 99.5,0.5"
fill-opacity="0"
Expand Down Expand Up @@ -462,7 +462,7 @@ exports[`Progress should support percentage array changes 1`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="49.5"
Expand Down Expand Up @@ -502,7 +502,7 @@ exports[`Progress should support percentage array changes 2`] = `
viewBox="0 0 100 100"
>
<circle
class="rc-progress-circle-trail"
class="rc-progress-circle-rail"
cx="50"
cy="50"
r="49.5"
Expand Down
6 changes: 3 additions & 3 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('Progress', () => {
steps={steps}
percent={percent}
strokeColor="red"
trailColor="grey"
railColor="grey"
strokeWidth={20}
/>,
);
Expand All @@ -199,7 +199,7 @@ describe('Progress', () => {
'0%': '#108ee9',
'100%': '#87d068',
}}
trailColor="grey"
railColor="grey"
strokeWidth={20}
/>,
);
Expand All @@ -215,7 +215,7 @@ describe('Progress', () => {
gapDegree={60}
percent={50}
strokeColor="red"
trailColor="grey"
railColor="grey"
strokeWidth={20}
/>,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/semantic.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Semantic', () => {
);

expect(container.querySelector('.rc-progress-circle')).toHaveClass(classNames.root);
expect(container.querySelector('.rc-progress-circle-trail')).toHaveClass(classNames.rail);
expect(container.querySelector('.rc-progress-circle-rail')).toHaveClass(classNames.rail);
expect(container.querySelector('.rc-progress-circle-path')).toHaveClass(classNames.track);

expect(container.querySelector('.my-root')).toHaveStyle(styles.root);
Expand Down