1
- import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
- import classNames from 'classnames' ;
4
-
5
- import { mapToCssModules } from './Shared/helper.js' ;
6
- //
7
- import CCard from './CCard' ;
8
- import CCardBody from './CCardBody' ;
9
- import CCardFooter from './CCardFooter' ;
10
- import { CIcon } from '@coreui/icons-react' ;
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import classNames from 'classnames'
4
+ import { mapToCssModules } from './Shared/helper.js'
11
5
12
6
//component - CoreUI / CWidgetIcon
13
7
14
- const CWidgetIcon = props => {
8
+ const CWidgetIcon = props => {
15
9
16
10
const {
17
11
className,
18
12
cssModule,
13
+ children,
19
14
//
20
15
header,
21
- mainText ,
22
- icon ,
16
+ text ,
17
+ iconPadding ,
23
18
color,
24
- footer,
25
- link,
26
- variant,
27
19
...attributes
28
20
} = props ;
29
21
30
- const padding = ( variant === '0' ? { card : 'p-3' , icon : 'p-3' } : ( variant === '1' ? {
31
- card : 'p-0' , icon : 'p-4' , lead : 'pt-3' ,
32
- } : { card : 'p-0' , icon : 'p-4 px-5' , lead : 'pt-3' } ) ) ;
33
-
34
- const card = { style : 'd-flex' , color : color , icon : icon , classes : '' } ;
35
- card . classes = mapToCssModules ( classNames ( className , card . style , padding . card , 'align-items-center' ) , cssModule ) ;
36
-
37
- const lead = { style : 'text-value' , color : color , classes : '' } ;
38
- lead . classes = classNames ( lead . style , 'text-' + card . color ) ;
39
-
40
- const blockIcon = function ( icon ) {
41
- const classes = classNames ( 'bg-' + card . color , 'text-white' , padding . icon , 'mr-3 float-left' ) ;
42
- return < div className = { classes } > < CIcon name = { icon } /> </ div >
43
- } ;
44
-
45
- const cardFooter = function ( ) {
46
- if ( footer ) {
47
- return (
48
- < CCardFooter className = "px-3 py-2" >
49
- < a className = "align-items-center btn-block d-flex justify-content-between text-muted" href = { link } >
50
- < span className = "small font-weight-bold" >
51
- View More
52
- </ span >
53
- < CIcon className = "float-right" name = "cil-chevron-right" size = "lg" />
54
- </ a >
55
- </ CCardFooter >
56
- ) ;
57
- }
58
- } ;
22
+ const classes = mapToCssModules ( classNames (
23
+ 'card' , color , className
24
+ ) , cssModule )
59
25
60
26
return (
61
- < CCard { ...attributes } >
62
- < CCardBody className = { card . classes } { ... attributes } >
63
- < div >
64
- { blockIcon ( card . icon ) }
27
+ < div className = { classes } { ...attributes } >
28
+ < div className = { ` card-body d-flex align-items-center ${ iconPadding ? 'p-3' : 'p-0' } ` } >
29
+ < div className = { `mr-3 text-white bg- ${ color } ${ iconPadding ? 'p-3' : 'p-4' } ` } >
30
+ { children }
65
31
</ div >
66
32
< div >
67
- < div className = { lead . classes } > { header } </ div >
68
- < div className = "text-muted text-uppercase font-weight-bold small" > { mainText } </ div >
33
+ { header && < div className = { `text-value text-${ color } ` } > { header } </ div > }
34
+ { text && < div className = "text-muted text-uppercase font-weight-bold small" >
35
+ { text } </ div > }
69
36
</ div >
70
- </ CCardBody >
71
- { cardFooter ( ) }
72
- </ CCard >
73
- ) ;
74
-
37
+ </ div >
38
+ </ div >
39
+ )
75
40
}
76
41
77
42
CWidgetIcon . propTypes = {
@@ -81,21 +46,13 @@ CWidgetIcon.propTypes = {
81
46
//
82
47
innerRef : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . func , PropTypes . string ] ) ,
83
48
header : PropTypes . string ,
84
- mainText : PropTypes . string ,
85
- icon : PropTypes . string ,
86
- color : PropTypes . string ,
87
- variant : PropTypes . string ,
88
- footer : PropTypes . bool ,
89
- link : PropTypes . string ,
49
+ text : PropTypes . string ,
50
+ iconPadding : PropTypes . bool ,
51
+ color : PropTypes . string
90
52
} ;
91
53
92
54
CWidgetIcon . defaultProps = {
93
- header : '$1,999.50' ,
94
- mainText : 'Widget title' ,
95
- icon : 'cil-settings' ,
96
- color : 'primary' ,
97
- variant : '0' ,
98
- link : '#' ,
55
+ iconPadding : true
99
56
} ;
100
57
101
- export default CWidgetIcon ;
58
+ export default CWidgetIcon
0 commit comments