Skip to content

Commit 58998c4

Browse files
committed
fix: progress borderRadius reactive #6409
1 parent 7db4265 commit 58998c4

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

components/progress/Circle.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export default defineComponent({
2828
props: initDefaultProps(circleProps(), {
2929
trailColor: null as unknown as string,
3030
}),
31-
setup(props, { slots }) {
32-
const originWidth = computed(() => props.width || 120);
31+
setup(props, { slots, attrs }) {
32+
const originWidth = computed(() => props.width ?? 120);
3333
const mergedSize = computed(() => props.size ?? [originWidth.value, originWidth.value]);
3434

3535
const sizeRef = computed(() => getSize(mergedSize.value as ProgressProps['size'], 'circle'));
@@ -87,7 +87,11 @@ export default defineComponent({
8787
/>
8888
);
8989
return (
90-
<div class={wrapperClassName.value} style={circleStyle.value}>
90+
<div
91+
{...attrs}
92+
class={[wrapperClassName.value, attrs.class]}
93+
style={[attrs.style as CSSProperties, circleStyle.value]}
94+
>
9195
{sizeRef.value.width <= 20 ? (
9296
<Tooltip v-slots={{ title: slots.default }}>
9397
<span>{circleContent}</span>

components/progress/Line.tsx

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
1+
import type { CSSProperties, ExtractPropTypes } from 'vue';
22
import { presetPrimaryColors } from '@ant-design/colors';
33
import { computed, defineComponent } from 'vue';
44
import type { Direction } from '../config-provider';
55
import type { StringGradients, ProgressGradient, ProgressSize } from './props';
66
import { progressProps } from './props';
77
import { getSize, getSuccessPercent, validProgress } from './utils';
88
import devWarning from '../vc-util/devWarning';
9-
import { anyType } from '../_util/type';
9+
import { anyType, stringType } from '../_util/type';
1010

1111
export const lineProps = () => ({
1212
...progressProps(),
1313
strokeColor: anyType<string | ProgressGradient>(),
14-
direction: {
15-
type: String as PropType<Direction>,
16-
},
14+
direction: stringType<Direction>(),
1715
});
1816

1917
export type LineProps = Partial<ExtractPropTypes<ReturnType<typeof lineProps>>>;
@@ -86,8 +84,9 @@ export default defineComponent({
8684
backgroundColor: strokeColor as string,
8785
};
8886
});
89-
const borderRadius =
90-
props.strokeLinecap === 'square' || props.strokeLinecap === 'butt' ? 0 : undefined;
87+
const borderRadius = computed(() =>
88+
props.strokeLinecap === 'square' || props.strokeLinecap === 'butt' ? 0 : undefined,
89+
);
9190

9291
const trailStyle = computed<CSSProperties>(() =>
9392
props.trailColor
@@ -118,7 +117,7 @@ export default defineComponent({
118117
return {
119118
width: `${validProgress(percent)}%`,
120119
height: `${sizeRef.value.height}px`,
121-
borderRadius,
120+
borderRadius: borderRadius.value,
122121
...backgroundProps.value,
123122
};
124123
});
@@ -131,7 +130,7 @@ export default defineComponent({
131130
return {
132131
width: `${validProgress(successPercent.value)}%`,
133132
height: `${sizeRef.value.height}px`,
134-
borderRadius,
133+
borderRadius: borderRadius.value,
135134
backgroundColor: success?.strokeColor,
136135
};
137136
});
@@ -143,7 +142,11 @@ export default defineComponent({
143142

144143
return () => (
145144
<>
146-
<div {...attrs} class={[`${props.prefixCls}-outer`, attrs.class]} style={outerStyle}>
145+
<div
146+
{...attrs}
147+
class={[`${props.prefixCls}-outer`, attrs.class]}
148+
style={[attrs.style as CSSProperties, outerStyle]}
149+
>
147150
<div class={`${props.prefixCls}-inner`} style={trailStyle.value}>
148151
<div class={`${props.prefixCls}-bg`} style={percentStyle.value} />
149152
{successPercent.value !== undefined ? (

components/progress/Steps.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
import type { ExtractPropTypes, PropType } from 'vue';
1+
import type { ExtractPropTypes } from 'vue';
22
import { computed, defineComponent } from 'vue';
33
import type { VueNode } from '../_util/type';
4-
import PropTypes from '../_util/vue-types';
4+
import { someType } from '../_util/type';
55
import type { ProgressSize } from './props';
66
import { progressProps } from './props';
77
import { getSize } from './utils';
88

99
export const stepsProps = () => ({
1010
...progressProps(),
1111
steps: Number,
12-
size: {
13-
type: String as PropType<ProgressSize>,
14-
},
15-
strokeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
12+
strokeColor: someType<string | string[]>(),
1613
trailColor: String,
1714
});
1815

components/progress/props.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { VueNode } from '../_util/type';
2-
import { someType, functionType, stringType, anyType, objectType } from '../_util/type';
2+
import {
3+
booleanType,
4+
someType,
5+
functionType,
6+
stringType,
7+
anyType,
8+
objectType,
9+
} from '../_util/type';
310
import type { ExtractPropTypes } from 'vue';
411

512
export const progressStatuses = ['normal', 'exception', 'active', 'success'] as const;
@@ -25,7 +32,7 @@ export const progressProps = () => ({
2532
percent: Number,
2633
format: functionType<(percent?: number, successPercent?: number) => VueNode>(),
2734
status: stringType<ProgressStatusesType>(),
28-
showInfo: { type: Boolean, default: undefined },
35+
showInfo: booleanType(),
2936
strokeWidth: Number,
3037
strokeLinecap: stringType<'butt' | 'square' | 'round'>(),
3138
strokeColor: anyType<string | string[] | ProgressGradient>(),
@@ -35,7 +42,7 @@ export const progressProps = () => ({
3542
success: objectType<SuccessProps>(),
3643
gapDegree: Number,
3744
gapPosition: stringType<'top' | 'bottom' | 'left' | 'right'>(),
38-
size: someType<ProgressSize>([String, Number, Array]),
45+
size: someType<ProgressSize | number | [number, number]>([String, Number, Array]),
3946
steps: Number,
4047
/** @deprecated Use `success` instead */
4148
successPercent: Number,

0 commit comments

Comments
 (0)