-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(checkboxgroup): New CheckBoxGroup, update CheckBox & asInput styles
feat(checkboxgroup): New CheckBoxGroup, update CheckBox & asInput styles
- Loading branch information
Showing
9 changed files
with
442 additions
and
23 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import "~bootstrap/scss/_forms"; | ||
@import "~bootstrap/scss/mixins/_forms"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
/* eslint-disable no-console */ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import CheckBoxGroup from './index'; | ||
import CheckBox from '../CheckBox'; | ||
|
||
storiesOf('CheckBoxGroup', module) | ||
.add('basic usage', () => ( | ||
<CheckBoxGroup> | ||
<CheckBox | ||
id="checkbox1" | ||
name="basicCheckBox" | ||
label="CheckBox 1" | ||
/> | ||
<CheckBox | ||
id="checkbox2" | ||
name="basicCheckBox" | ||
label="CheckBox 2" | ||
/> | ||
<CheckBox | ||
id="checkbox3" | ||
name="basicCheckBox" | ||
label="CheckBox 3" | ||
/> | ||
</CheckBoxGroup> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import CheckBoxGroup from './index'; | ||
import CheckBox from '../CheckBox'; | ||
|
||
describe('<CheckBoxGroup />', () => { | ||
it('correct number of children displayed in group', () => { | ||
const checkBoxGroup = ( | ||
<CheckBoxGroup> | ||
<CheckBox | ||
id="checkbox1" | ||
name="basicCheckBox" | ||
label="CheckBox 1" | ||
/> | ||
<CheckBox | ||
id="checkbox2" | ||
name="basicCheckBox" | ||
label="CheckBox 2" | ||
/> | ||
<CheckBox | ||
id="checkbox3" | ||
name="basicCheckBox" | ||
label="CheckBox 3" | ||
/> | ||
</CheckBoxGroup> | ||
); | ||
const wrapper = mount(checkBoxGroup); | ||
|
||
expect(wrapper.find('[id="checkbox1"]').exists()).toEqual(true); | ||
expect(wrapper.find('[id="checkbox2"]').exists()).toEqual(true); | ||
expect(wrapper.find('[id="checkbox3"]').exists()).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CheckBoxGroup | ||
|
||
CheckboxGroup is a group of the CheckBox components. It takes CheckBox components as children and wraps them in the bootstrap `form-group` styling. See `CheckBox` description for more details | ||
|
||
## API | ||
|
||
### `children` (array of `CheckBox`; required) | ||
`children` represents the CheckBox components defined within the CheckBoxGroup component and is not a specific named prop that needs to be passed in. At least one CheckBox must be defined within the group. Example: `<CheckBoxGroup><CheckBox .../></CheckBoxGroup>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ElementPropTypes from 'react-element-proptypes'; | ||
|
||
import CheckBox from '../CheckBox'; | ||
import styles from './CheckBoxGroup.scss'; | ||
|
||
function CheckBoxGroup(props) { | ||
return ( | ||
<div className={styles['form-group']}> | ||
{props.children} | ||
</div> | ||
); | ||
} | ||
|
||
CheckBoxGroup.propTypes = { | ||
children: PropTypes.arrayOf(ElementPropTypes.elementOfType(CheckBox)).isRequired, | ||
}; | ||
|
||
export default CheckBoxGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters