1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
+ import { themr } from 'react-css-themr' ;
3
4
import cx from 'classnames' ;
4
5
5
- import styles from './theme.scss' ;
6
+ import defaultTheme from './theme.module .scss' ;
6
7
7
8
class RadioButtonGroup extends React . Component {
8
9
constructor ( props ) {
@@ -29,7 +30,7 @@ class RadioButtonGroup extends React.Component {
29
30
theme,
30
31
} = this . props ;
31
32
32
- const classNames = cx ( styles [ 'radio-group' ] , { inline } ) ;
33
+ const classNames = cx ( theme [ 'radio-group' ] , { [ theme . inline ] : inline } ) ;
33
34
34
35
const isChecked = label => label === this . state . currentlyActive ? 'active' : '' ; // eslint-disable-line
35
36
@@ -40,16 +41,16 @@ class RadioButtonGroup extends React.Component {
40
41
{ /* eslint-disable jsx-a11y/click-events-have-key-events */ }
41
42
{ /* eslint-disable jsx-a11y/no-static-element-interactions */ }
42
43
< div
43
- className = { cx ( styles [ 'each-radio' ] ) }
44
+ className = { cx ( theme [ 'each-radio' ] ) }
44
45
onClick = { ( e ) => { this . handleRadioBtnChange ( e , option ) ; } }
45
46
id = "radio_button"
46
47
>
47
- < label className = { cx ( styles [ 'customized-radio' ] , theme [ 'customized-radio' ] ) } >
48
- < label className = { cx ( ' inner' , { checked : isChecked ( option . label ) } ) } >
48
+ < label className = { cx ( theme [ 'customized-radio' ] , theme [ 'customized-radio' ] ) } >
49
+ < label className = { cx ( theme . inner , { [ theme . checked ] : isChecked ( option . label ) } ) } >
49
50
< input type = "radio" />
50
51
</ label >
51
52
</ label >
52
- < label className = { styles [ 'each-label' ] } >
53
+ < label className = { theme [ 'each-label' ] } >
53
54
{ option . label }
54
55
</ label >
55
56
</ div >
@@ -64,13 +65,13 @@ RadioButtonGroup.propTypes = {
64
65
options : PropTypes . oneOfType ( [ PropTypes . array ] ) . isRequired ,
65
66
inline : PropTypes . bool ,
66
67
onClick : PropTypes . func ,
67
- theme : PropTypes . string ,
68
+ theme : PropTypes . oneOfType ( [ PropTypes . object ] ) ,
68
69
} ;
69
70
70
71
RadioButtonGroup . defaultProps = {
71
72
inline : false ,
72
73
onClick : ( ) => { } ,
73
- theme : '' ,
74
+ theme : defaultTheme ,
74
75
} ;
75
76
76
- export default RadioButtonGroup ;
77
+ export default themr ( 'CBRadioButtonGroup' , defaultTheme ) ( RadioButtonGroup ) ;
0 commit comments