mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-11-30 02:08:12 +08:00
fix(components): [progress] setting both color and striped is invalid (#17235)
* fix(components): [progress] setting both color and striped is invalid * chore: fix test
This commit is contained in:
parent
a8a2298a6d
commit
58b60e52dc
@ -67,7 +67,7 @@ describe('Progress.vue', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('.el-progress-bar__inner').attributes('style')
|
wrapper.find('.el-progress-bar__inner').attributes('style')
|
||||||
).toContain('background: rgb(255, 255, 255);')
|
).toContain('background-color: rgb(255, 255, 255);')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('striped', () => {
|
test('striped', () => {
|
||||||
@ -103,7 +103,7 @@ describe('Progress.vue', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('.el-progress-bar__inner').attributes('style')
|
wrapper.find('.el-progress-bar__inner').attributes('style')
|
||||||
).toContain('background: rgb(1, 2, 3);')
|
).toContain('background-color: rgb(1, 2, 3);')
|
||||||
|
|
||||||
percentage.value = 60
|
percentage.value = 60
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ describe('Progress.vue', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('.el-progress-bar__inner').attributes('style')
|
wrapper.find('.el-progress-bar__inner').attributes('style')
|
||||||
).toContain('background: rgb(4, 5, 6);')
|
).toContain('background-color: rgb(4, 5, 6);')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('color is array', async () => {
|
test('color is array', async () => {
|
||||||
@ -131,14 +131,14 @@ describe('Progress.vue', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('.el-progress-bar__inner').attributes('style')
|
wrapper.find('.el-progress-bar__inner').attributes('style')
|
||||||
).toContain('background: rgb(1, 1, 1);')
|
).toContain('background-color: rgb(1, 1, 1);')
|
||||||
|
|
||||||
percentage.value = 89
|
percentage.value = 89
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('.el-progress-bar__inner').attributes('style')
|
wrapper.find('.el-progress-bar__inner').attributes('style')
|
||||||
).toContain('background: rgb(9, 9, 9);')
|
).toContain('background-color: rgb(9, 9, 9);')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('format', () => {
|
test('format', () => {
|
||||||
|
@ -112,11 +112,19 @@ const props = defineProps(progressProps)
|
|||||||
|
|
||||||
const ns = useNamespace('progress')
|
const ns = useNamespace('progress')
|
||||||
|
|
||||||
const barStyle = computed<CSSProperties>(() => ({
|
const barStyle = computed<CSSProperties>(() => {
|
||||||
width: `${props.percentage}%`,
|
const barStyle: CSSProperties = {
|
||||||
animationDuration: `${props.duration}s`,
|
width: `${props.percentage}%`,
|
||||||
background: getCurrentColor(props.percentage),
|
animationDuration: `${props.duration}s`,
|
||||||
}))
|
}
|
||||||
|
const color = getCurrentColor(props.percentage)
|
||||||
|
if (color.includes('gradient')) {
|
||||||
|
barStyle.background = color
|
||||||
|
} else {
|
||||||
|
barStyle.backgroundColor = color
|
||||||
|
}
|
||||||
|
return barStyle
|
||||||
|
})
|
||||||
|
|
||||||
const relativeStrokeWidth = computed(() =>
|
const relativeStrokeWidth = computed(() =>
|
||||||
((props.strokeWidth / props.width) * 100).toFixed(1)
|
((props.strokeWidth / props.width) * 100).toFixed(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user