feat(Progress): add track-color prop (#4789)

This commit is contained in:
neverland 2019-10-20 13:02:30 +08:00 committed by GitHub
parent 4c2cf8e2cb
commit 95598e8842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -68,6 +68,7 @@ Use `pivot-text` to custom textuse `color` to custom bar color
| stroke-width | Stroke width | *string \| number* | `4px` | 2.2.1 |
| show-pivot | Whether to show text | *boolean* | `true` | - |
| color | Color | *string* | `#1989fa` | - |
| text-color | Text color | *string* | `#fff` | - |
| track-color | Track color | *string* | `#e5e5e5` | 2.2.9 |
| pivot-text | Text | *string* | percentage | - |
| pivot-color | Text background color | *string* | inherit progress color | - |
| text-color | Text color | *string* | `#fff` | - |

View File

@ -71,6 +71,7 @@ Vue.use(Progress);
| stroke-width | 进度条粗细,默认单位为`px` | *string \| number* | `4px` | 2.2.1 |
| show-pivot | 是否显示进度文字 | *boolean* | `true` | - |
| color | 进度条颜色 | *string* | `#1989fa` | - |
| text-color | 进度条文字颜色 | *string* | `#fff` | - |
| text-color | 进度文字颜色 | *string* | `#fff` | - |
| track-color | 轨道颜色 | *string* | `#e5e5e5` | 2.2.9 |
| pivot-text | 文字显示 | *string* | 百分比文字 | - |
| pivot-color | 文字背景色 | *string* | 与进度条颜色一致 | - |

View File

@ -8,6 +8,7 @@ export default createComponent({
inactive: Boolean,
pivotText: String,
pivotColor: String,
trackColor: String,
strokeWidth: [String, Number],
percentage: {
type: Number,
@ -70,12 +71,10 @@ export default createComponent({
width: (this.progressWidth * percentage) / 100 + 'px'
};
let wrapperStyle;
if (this.strokeWidth) {
wrapperStyle = {
height: addUnit(this.strokeWidth)
};
}
const wrapperStyle = {
background: this.trackColor,
height: addUnit(this.strokeWidth)
};
return (
<div class={bem()} style={wrapperStyle}>

View File

@ -16,3 +16,13 @@ test('calc width', async () => {
await later();
expect(wrapper).toMatchSnapshot();
});
test('track color prop', async () => {
const wrapper = mount(Progress, {
propsData: {
trackColor: 'green'
}
});
expect(wrapper.element.style.background).toEqual('green');
});