Skip to content

Commit b483590

Browse files
committed
🎨 Update radiobutton group with react css themr
1 parent bd98ba2 commit b483590

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/radioButtonGroup/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { themr } from 'react-css-themr';
34
import cx from 'classnames';
45

5-
import styles from './theme.scss';
6+
import defaultTheme from './theme.module.scss';
67

78
class RadioButtonGroup extends React.Component {
89
constructor(props) {
@@ -29,7 +30,7 @@ class RadioButtonGroup extends React.Component {
2930
theme,
3031
} = this.props;
3132

32-
const classNames = cx(styles['radio-group'], { inline });
33+
const classNames = cx(theme['radio-group'], { [theme.inline]: inline });
3334

3435
const isChecked = label => label === this.state.currentlyActive ? 'active' : ''; // eslint-disable-line
3536

@@ -40,16 +41,16 @@ class RadioButtonGroup extends React.Component {
4041
{/* eslint-disable jsx-a11y/click-events-have-key-events */ }
4142
{ /* eslint-disable jsx-a11y/no-static-element-interactions */ }
4243
<div
43-
className={cx(styles['each-radio'])}
44+
className={cx(theme['each-radio'])}
4445
onClick={(e) => { this.handleRadioBtnChange(e, option); }}
4546
id="radio_button"
4647
>
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) })}>
4950
<input type="radio" />
5051
</label>
5152
</label>
52-
<label className={styles['each-label']}>
53+
<label className={theme['each-label']}>
5354
{option.label}
5455
</label>
5556
</div>
@@ -64,13 +65,13 @@ RadioButtonGroup.propTypes = {
6465
options: PropTypes.oneOfType([PropTypes.array]).isRequired,
6566
inline: PropTypes.bool,
6667
onClick: PropTypes.func,
67-
theme: PropTypes.string,
68+
theme: PropTypes.oneOfType([PropTypes.object]),
6869
};
6970

7071
RadioButtonGroup.defaultProps = {
7172
inline: false,
7273
onClick: () => {},
73-
theme: '',
74+
theme: defaultTheme,
7475
};
7576

76-
export default RadioButtonGroup;
77+
export default themr('CBRadioButtonGroup', defaultTheme)(RadioButtonGroup);

0 commit comments

Comments
 (0)