Skip to content

Commit d80df69

Browse files
committed
fixed issues related to structuring checkbox group
1 parent 39badab commit d80df69

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/checkboxGroup/index.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,23 @@ class CheckboxGroup extends React.Component {
3030
inline,
3131
} = this.props;
3232

33-
const classNames = cx(styles['checkbox-group'], { inline });
33+
const classNames = cx(styles['checkbox-group']);
3434
return options.map(option => (
35-
<div key={option.label} className={classNames}>
36-
<div className={styles['each-check']}>
37-
<Checkbox
38-
{...option}
39-
checked={this.state.isChecked[option.label]}
40-
onClick={this.handleCheckListChange}
41-
/>
42-
<label className={styles['each-label']}>
43-
{option.label}
44-
</label>
35+
<React.Fragment key={option.label}>
36+
<div className={classNames}>
37+
<div className={cx(styles['each-check'], { inline })}>
38+
<Checkbox
39+
{...option}
40+
checked={this.state.isChecked[option.label]}
41+
onClick={this.handleCheckListChange}
42+
/>
43+
<label className={styles['each-label']}>
44+
{option.label}
45+
</label>
46+
</div>
4547
</div>
46-
</div>
48+
<div className="clearfix" />
49+
</React.Fragment>
4750
));
4851
}
4952
}

src/checkboxGroup/style.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
:local(.checkbox-group) {
22

3+
.clearfix {
4+
clear: both;
5+
}
36
}
47

58
:local(.each-check) {
9+
&.inline {
10+
float: left;
11+
margin-right: 25px;
12+
}
613
margin-bottom: 10px;
714
}
815

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const CheckboxDemo = () => (
2121
<React.Fragment>
2222
<CheckboxGroup
2323
options={options}
24+
inline
2425
/>
2526
</React.Fragment>
2627
);

0 commit comments

Comments
 (0)