Skip to content

Commit

Permalink
4.1.0: Add support for inline prop
Browse files Browse the repository at this point in the history
  • Loading branch information
kwltrs committed Dec 22, 2016
1 parent 07c2107 commit d1811f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 4.1.0
* Option to remove `ffe-checkbox--inline` by adding the property `inline=false`.

## 4.0.0
* Added support for ffe-form version 4.x

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-checkbox-react",
"version": "4.0.0",
"version": "4.1.0",
"main": "lib/checkbox.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/. && npm run example",
Expand Down
11 changes: 8 additions & 3 deletions src/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function CheckBox(props) {
children,
label,
noMargins,
onChange,
inline,
...rest,
} = props;

Expand All @@ -16,7 +16,6 @@ export default function CheckBox(props) {
return (
<span>
<input
onChange={onChange || (f => f)}
className="ffe-hidden-checkbox"
id={id}
type="checkbox"
Expand All @@ -25,7 +24,7 @@ export default function CheckBox(props) {
<label
className={classNames({
'ffe-checkbox': true,
'ffe-checkbox--inline': true,
'ffe-checkbox--inline': inline,
'ffe-checkbox--no-margin': noMargins
})}
htmlFor={id}
Expand All @@ -41,5 +40,11 @@ CheckBox.propTypes = {
onChange: PropTypes.func,
checked: PropTypes.bool,
noMargins: PropTypes.bool,
inline: PropTypes.bool,
children: PropTypes.array,
};

CheckBox.defaultProps = {
noMargins: false,
inline: true
};
14 changes: 14 additions & 0 deletions src/checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ describe('<Checkbox />', () => {
1);
});

it('should support inline', () => {
assert.equal(
shallow(CreateCheckbox()).find('.ffe-checkbox--inline').length,
1);

assert.equal(
shallow(CreateCheckbox({ inline: false })).find('.ffe-checkbox--inline').length,
0);

assert.equal(
shallow(CreateCheckbox({ inline: true })).find('.ffe-checkbox--inline').length,
1);
});

it('should set arbitrary props (rest) on input', () => {
const wrapper = shallow(CreateCheckbox({
name: 'checkbox',
Expand Down

0 comments on commit d1811f5

Please sign in to comment.