Skip to content

Commit

Permalink
feat(radio): Classname and style passes through to radio div
Browse files Browse the repository at this point in the history
[Finishes #98913402]
  • Loading branch information
Kenny Wang committed Jul 17, 2015
1 parent 3f533de commit 9f736c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 14 additions & 0 deletions spec/pivotal-ui-react/radio/radio_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ describe('Radio', function() {
});
});
});

describe('when className and style are passed', () => {
beforeEach(() =>{
React.render(
<Radio value="1" name="bananas" className="radio-class" style={{opacity: '1'}} defaultChecked>
One!!!
</Radio>, root);
});
it('passes through className and style', () => {
expect('#root .radio').toHaveClass('radio-class');
expect('#root .radio').toHaveCss({opacity: '1'});
});
});

});
7 changes: 5 additions & 2 deletions src/pivotal-ui-react/radio/radio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var React = require('react');
import {mergeProps} from '../../../src/pivotal-ui-react/helpers/helpers';

/**
* @component Radio
Expand Down Expand Up @@ -34,9 +35,11 @@ var Radio = React.createClass({
},

render: function() {
const {className, style, ...others} = this.props;
const props = mergeProps({className: className, style: style}, {className: 'radio'});
return (
<div className="radio">
<label><input type="radio" {...this.props}/></label>
<div {...props}>
<label><input type="radio" {...others}/></label>
</div>
);
}
Expand Down

0 comments on commit 9f736c9

Please sign in to comment.