Skip to content

Commit 1d4c202

Browse files
committed
refactor: change CProgressBar prop color to variant for unification
1 parent 3ff8b14 commit 1d4c202

File tree

4 files changed

+13
-23
lines changed

4 files changed

+13
-23
lines changed

src/components/Progress/CProgress.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
value: this.value,
1515
max: this.max,
1616
precision: this.precision,
17-
color: this.color,
17+
variant: this.variant,
1818
animated: this.animated,
1919
striped: this.striped,
2020
showProgress: this.showProgress,
@@ -35,12 +35,12 @@ export default {
3535
props: {
3636
height: String,
3737
// These props can be inherited via the child CProgressBar(s)
38-
color: String,
38+
variant: String,
3939
striped: Boolean,
4040
animated: Boolean,
4141
precision: Number,
4242
showProgress: Boolean,
43-
showValue: Boolean,
43+
showValue: Boolean,
4444
max: Number,
4545
// This prop is not inherited by child CProgressBar(s)
4646
value: Number,

src/components/Progress/CProgressBar.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { getColor } from '@coreui/coreui/dist/js/coreui-utilities'
2-
31
export default {
42
name: 'CProgressBar',
53
render (h) {
@@ -32,17 +30,15 @@ export default {
3230
progressBarClasses () {
3331
return [
3432
'progress-bar',
33+
this.computedVariant ? `bg-${this.computedVariant}` : '',
3534
{
3635
'progress-bar-striped': this.computedStriped || this.computedAnimated,
3736
'progress-bar-animated': this.computedAnimated
3837
}
3938
]
4039
},
4140
progressBarStyles () {
42-
return [
43-
{ width: `${(100 * (this.value / this.computedMax))}%` },
44-
this.computedColor? { backgroundColor: this.computedColor} : {}
45-
]
41+
return { width: `${(100 * (this.value / this.computedMax))}%` }
4642
},
4743
progress () {
4844
const p = Math.pow(10, this.computedPrecision)
@@ -52,9 +48,9 @@ export default {
5248
// Prefer our max over parent setting
5349
return this.max ? this.max : (this.$parent.max || 100)
5450
},
55-
computedColor () {
56-
// Prefer our color over parent setting
57-
return getColor(this.color || this.$parent.color || '#fff')
51+
computedVariant () {
52+
// Prefer our variant over parent setting
53+
return this.variant || this.$parent.variant
5854
},
5955
computedPrecision () {
6056
// Prefer our precision over parent setting
@@ -83,7 +79,7 @@ export default {
8379
// Which is why they are defaulted to null
8480
max: Number,
8581
precision: Number,
86-
color: String,
82+
variant: String,
8783
striped: {
8884
type: Boolean,
8985
default: null

src/components/Widgets/CWidget01.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="h4 m-0">{{props.header}}</div>
55
<div>{{props.text}}</div>
66
<slot>
7-
<CProgress :color="!props.inverse ? props.variant : ''"
7+
<CProgress :variant="!props.inverse ? props.variant : ''"
88
:value = "props.value"
99
:class="props.inverse ? 'progress-white' : ''"
1010
class="progress-xs my-3 mb-0"/>
@@ -34,10 +34,7 @@ export default {
3434
type: String,
3535
default: 'footer:string'
3636
},
37-
variant: {
38-
type: String,
39-
default: 'success'
40-
},
37+
variant: String,
4138
inverse: Boolean,
4239
value: {
4340
type: Number,

src/components/Widgets/CWidget05.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="h4 mb-0">{{props.header}}</div>
88
<small class="text-muted text-uppercase font-weight-bold">{{props.text}}</small>
99
<slot>
10-
<CProgress :color="!props.inverse ? props.variant : ''"
10+
<CProgress :variant="!props.inverse ? props.variant : ''"
1111
:value="props.value"
1212
:class="props.inverse ? 'progress-white' : ''"
1313
class="progress-xs my-3 mb-0"/>
@@ -36,10 +36,7 @@ export default {
3636
type: String,
3737
default: 'text:string'
3838
},
39-
variant: {
40-
type: String,
41-
default: 'success'
42-
},
39+
variant: String,
4340
inverse: Boolean,
4441
value: {
4542
type: Number,

0 commit comments

Comments
 (0)