Skip to content

Commit

Permalink
Container: provide a way to clear floated children without hiding ove…
Browse files Browse the repository at this point in the history
…rflow
  • Loading branch information
jossmac committed Sep 3, 2015
1 parent 4226ed8 commit 306e033
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = React.createClass({
displayName: 'Container',
propTypes: {
children: React.PropTypes.node.isRequired,
clearfix: React.PropTypes.bool,
gutter: React.PropTypes.number,
maxWidth: React.PropTypes.number,
style: React.PropTypes.object,
Expand All @@ -25,8 +26,17 @@ module.exports = React.createClass({
paddingRight: gutter,
maxWidth: maxWidth,
};
let clearfixStyle = { clear: 'both', display: 'table' };
let props = blacklist(this.props, 'gutter', 'maxWidth', 'style');

return <div style={Object.assign(containerStyle, this.props.style)} {...props} />;
return this.props.clearfix ? (
<div style={Object.assign(containerStyle, this.props.style)} {...props}>
<span style={clearfixStyle} />
{this.props.children}
<span style={clearfixStyle} />
</div>
) : (
<div style={Object.assign(containerStyle, this.props.style)} {...props} />
);
}
});

0 comments on commit 306e033

Please sign in to comment.