Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple inline styles #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-cellblock",
"version": "2.0.0",
"version": "2.0.1",
"description": "A react-based grid for smarter responsive components",
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions src/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class Column extends Component {
className: PropTypes.string,
isRoot: PropTypes.bool,
offset: gridFraction,
style: PropTypes.object,
viewport: PropTypes.array,
width: gridFraction
};
Expand Down Expand Up @@ -76,7 +77,7 @@ export default class Column extends Component {
style.width = decimalToPercent(width[0] / width[1]);

return (
<div className={className} style={style}>
<div className={className} style={{ ...style, ...this.props.style }}>
{this.props.children}
</div>
);
Expand All @@ -90,4 +91,4 @@ function fractionToPercent(v) {

function decimalToPercent(v) {
return parseFloat((v * 100).toFixed(4)) + '%';
}
}
9 changes: 5 additions & 4 deletions src/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default class Grid extends Component {
flexible: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
gutterWidth: PropTypes.number,
initialBreakpoint: validBreakpoint,
onChange: PropTypes.func
onChange: PropTypes.func,
style: PropTypes.object
};

static childContextTypes = gridContext;
Expand Down Expand Up @@ -126,13 +127,13 @@ export default class Grid extends Component {

render() {
const {breakpoint, breakCount} = this.state;
const {className, gutterWidth, children} = this.props;
const {className, gutterWidth, children, style} = this.props;
const breakPointRange = [breakpoint, this.getMaxBreatPoint(breakpoint)];
return (
<Column isRoot viewport={breakPointRange} breakCount={breakCount} className={className}>
<Column isRoot viewport={breakPointRange} breakCount={breakCount} className={className} style={style}>
<Style gutter={gutterWidth}/>
{children}
</Column>
);
}
}
}
7 changes: 4 additions & 3 deletions src/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {forceContext} from './util/handleStaleContext';
export default class Row extends Component {
static propTypes = {
children: PropTypes.any,
className: PropTypes.string
className: PropTypes.string,
style: PropTypes.object
};

static contextTypes = gridContext;
Expand All @@ -44,9 +45,9 @@ export default class Row extends Component {
};

return (
<div className={classnames(ROW, this.props.className)} style={style}>
<div className={classnames(ROW, this.props.className)} style={{ ...style, ...this.props.style }}>
{this.props.children}
</div>
);
}
}
}