1
1
import { defineComponent , h } from 'vue'
2
+ import { shape } from 'vue-types'
2
3
4
+ import { Color } from '../props'
3
5
import { CCard , CCardBody } from './../card'
4
6
import { CProgress } from '../progress/CProgress'
5
7
6
- const CWidgetProgress = defineComponent ( {
7
- name : 'CWidgetProgress ' ,
8
+ const CWidgetStatsB = defineComponent ( {
9
+ name : 'CWidgetStatsB ' ,
8
10
props : {
9
11
/**
10
- * Sets the color context of the component to one of CoreUI’s themed colors. [docs]
12
+ * Sets the color context of the component to one of CoreUI’s themed colors
11
13
*
12
14
* @values 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
13
15
*/
14
- color : {
15
- type : String ,
16
- default : undefined ,
17
- require : false ,
18
- } ,
16
+ color : Color ,
17
+ /**
18
+ * Colors have been inverted from their default dark shade.
19
+ */
19
20
inverse : {
20
21
type : Boolean ,
21
22
default : undefined ,
22
23
require : false ,
23
24
} ,
25
+ progress : shape ( {
26
+ /**
27
+ * Sets the color context of the progress bar to one of CoreUI’s themed colors
28
+ *
29
+ * @values 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
30
+ */
31
+ color : Color ,
32
+ /**
33
+ * The percent to progress the ProgressBar (out of 100).
34
+ * @default 0
35
+ */
36
+ value : {
37
+ type : Number ,
38
+ default : 0 ,
39
+ } ,
40
+ } ) ,
24
41
/**
25
- * Sets the color context of the progress bar to one of CoreUI’s themed colors. [docs]
26
- *
27
- * @values 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
42
+ * Helper text for your component. If you want to pass non-string value please use dedicated slot `<template #text>...</template>`
28
43
*/
29
- progressColor : {
30
- type : String ,
31
- default : undefined ,
32
- require : false ,
33
- } ,
34
- progressValue : {
35
- type : Number ,
36
- default : 0 ,
37
- require : false ,
38
- } ,
39
44
text : {
40
45
type : String ,
41
46
default : undefined ,
42
47
require : false ,
43
48
} ,
49
+ /**
50
+ * Title node for your component. If you want to pass non-string value please use dedicated slot `<template #title>...</template>`
51
+ */
44
52
title : {
45
53
type : String ,
46
54
default : undefined ,
47
55
require : false ,
48
56
} ,
57
+ /**
58
+ * Value node for your component. If you want to pass non-string value please use dedicated slot `<template #value>...</template>`
59
+ */
49
60
value : {
50
61
type : [ Number , String ] ,
51
62
default : 0 ,
52
63
require : false ,
53
64
} ,
54
65
} ,
55
- setup ( props ) {
66
+ setup ( props , { slots } ) {
56
67
return ( ) =>
57
68
h (
58
69
CCard ,
59
70
{
60
71
class : [
61
72
{
62
- [ 'text-white ' ] : props . inverse ,
73
+ [ 'text-high-emphasis-inverse ' ] : props . inverse ,
63
74
} ,
64
75
] ,
65
76
color : props . color ,
@@ -71,32 +82,32 @@ const CWidgetProgress = defineComponent({
71
82
class : 'card-body' ,
72
83
} ,
73
84
( ) => [
74
- props . value &&
85
+ ( props . value || slots . value ) &&
75
86
h (
76
87
'div' ,
77
88
{
78
89
class : 'fs-4 fw-semibold' ,
79
90
} ,
80
91
{
81
- default : ( ) => props . value ,
92
+ default : ( ) => ( slots . value && slots . value ( ) ) || props . value ,
82
93
} ,
83
94
) ,
84
- props . title &&
95
+ ( props . title || slots . title ) &&
85
96
h (
86
97
'div' ,
87
98
{ } ,
88
99
{
89
- default : ( ) => props . title ,
100
+ default : ( ) => ( slots . title && slots . title ( ) ) || props . title ,
90
101
} ,
91
102
) ,
92
103
h ( CProgress , {
93
104
class : 'my-2' ,
94
- color : props . progressColor ,
105
+ color : props . progress ?. color ,
95
106
height : 4 ,
96
- value : props . progressValue ,
107
+ value : props . progress ?. value ,
97
108
white : props . inverse ,
98
109
} ) ,
99
- props . text &&
110
+ ( props . text || slots . text ) &&
100
111
h (
101
112
'small' ,
102
113
{
@@ -105,7 +116,7 @@ const CWidgetProgress = defineComponent({
105
116
] ,
106
117
} ,
107
118
{
108
- default : ( ) => props . text ,
119
+ default : ( ) => ( slots . text && slots . text ( ) ) || props . text ,
109
120
} ,
110
121
) ,
111
122
] ,
@@ -114,4 +125,4 @@ const CWidgetProgress = defineComponent({
114
125
} ,
115
126
} )
116
127
117
- export { CWidgetProgress }
128
+ export { CWidgetStatsB }
0 commit comments