Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from JSBros/fixes
Browse files Browse the repository at this point in the history
v0.2.0 Release
  • Loading branch information
Garet McKinley authored Nov 12, 2016
2 parents 3e03d30 + 716f262 commit 0ff209c
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 46 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Changed

## [v0.2.0] - 2016-11-12

### Added

- New `Page` component! Use this as a top-level wrapper.
- Added a new debug mode! Add the `debug` property to any `Row` component to try it out.
- Added `xs` property to `Column`
- Added `xsShift` property to `Column`

### Changed

- Switched the `children` property of the `Row` component to be a `node` instead of an `element`.
- Refactored media utility.

## [v0.1.3] - 2016-11-11

### Added
Expand Down Expand Up @@ -44,7 +58,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Made progress on code comments
- Various linting

[Unreleased]: https://github.com/JSBros/hedron/compare/v0.1.3...master
[Unreleased]: https://github.com/JSBros/hedron/compare/v0.2.0...master
[v0.2.0]: https://github.com/JSBros/hedron/compare/v0.1.3...v0.2.0
[v0.1.3]: https://github.com/JSBros/hedron/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/JSBros/hedron/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/JSBros/hedron/compare/v0.1.0...v0.1.1
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": "hedron",
"version": "0.1.3",
"version": "0.2.0",
"description": "A no-frills flexbox grid system for React.",
"main": "dist/hedron.js",
"author": {
Expand Down
74 changes: 48 additions & 26 deletions src/components/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { divvy, media } from '../utils';


function ColumnContainer(props) {
const { divisions, fluid, xs, sm, md, lg,
smShift, mdShift, lgShift, ...rest } = props;
const { debug, divisions, fluid, xs, sm, md, lg,
xsShift, smShift, mdShift, lgShift,
...rest } = props;
return <div {...rest} />;
}

Expand All @@ -19,6 +20,7 @@ ColumnContainer.propTypes = {
sm: React.PropTypes.number,
md: React.PropTypes.number,
lg: React.PropTypes.number,
xsShift: React.PropTypes.number,
smShift: React.PropTypes.number,
mdShift: React.PropTypes.number,
lgShift: React.PropTypes.number
Expand All @@ -30,39 +32,59 @@ ColumnContainer.defaultProps = {

const Column = styled(ColumnContainer)`
display: block;
${props => props.debug ? `background-color: rgba(50, 50, 255, .1);
border: 1px solid #fff;` : ''}
box-sizing: border-box;
${props => props.fluid ? 'padding: 0;' : 'padding: 20px;'}
${props =>
props.fluid ? 'padding: 0;' : 'padding: 20px;'
}
width: 100%;
${props => props.xsShift ? `
margin-left: ${divvy(props.divisions) * props.xsShift}%;
` : ''}
${props =>
props.xs
? `width: ${divvy(props.divisions) * props.xs}%;`
: null
}
${props =>
props.xsShift
? `margin-left: ${divvy(props.divisions) * props.xsShift}%;`
: null
}
${media.sm`
${props => props.sm ? `
width: ${divvy(props.divisions) * props.sm}%;
` : ''}
${props => props.smShift ? `
margin-left: ${divvy(props.divisions) * props.smShift}%;
` : ''}
${props =>
props.sm
? `width: ${divvy(props.divisions) * props.sm}%;`
: null
}
${props => props.smShift
? `margin-left: ${divvy(props.divisions) * props.smShift}%;`
: null
}
`}
${media.md`
${props => props.md ? `
width: ${divvy(props.divisions) * props.md}%;
` : ''}
${props => props.mdShift ? `
margin-left: ${divvy(props.divisions) * props.mdShift}%;
` : ''}
${props =>
props.md
? `width: ${divvy(props.divisions) * props.md}%;`
: null
}
${props =>
props.mdShift
? `margin-left: ${divvy(props.divisions) * props.mdShift}%;`
: null
}
`}
${media.lg`
${props => props.lg ? `
width: ${divvy(props.divisions) * props.lg}%;
` : ''}
${props => props.lgShift ? `
margin-left: ${divvy(props.divisions) * props.lgShift}%;
` : ''}
${props =>
props.lg
? `width: ${divvy(props.divisions) * props.lg}%;`
: null
}
${props =>
props.lgShift
? `margin-left: ${divvy(props.divisions) * props.lgShift}%;`
: null
}
`}
`;


export default Column;

27 changes: 27 additions & 0 deletions src/components/Page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import styled from 'styled-components';

const Page = styled.div`
${props =>
props.fluid
? 'width: 100%;'
: `
margin: 0 auto;
max-width: 100%;
${props.width
? `
width: ${props.width};
`
: 'width: 960px;'
}
`
}
`;

Page.propTypes = {
fluid: React.PropTypes.bool,
width: React.PropTypes.string
};

export default Page;

6 changes: 4 additions & 2 deletions src/components/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import { divvy } from '../utils';


function RowContainer(props) {
const { children, divisions, ...rest } = props;
const { children, debug, divisions, ...rest } = props;
const scaledChildren = React.Children.map(children,
child => React.cloneElement(child, {
debug,
divisions
})
);
return <section {...rest}>{scaledChildren}</section>;
}

RowContainer.propTypes = {
children: React.PropTypes.element,
children: React.PropTypes.node,
className: React.PropTypes.string,
debug: React.PropTypes.bool,
divisions: React.PropTypes.number
};

Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Column from './components/Column';
import Row from './components/Row';
import Page from './components/Page';
import { divvy, media } from './utils';

const utils = {
divvy,
media
};

export { Column, Row, utils };
export { Column, Page, Row, utils };

28 changes: 13 additions & 15 deletions src/utils/media.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { css } from 'styled-components';

export default {
sm: (...args) => css`
@media (min-width: 500px) {
${css(...args)}
}
`,
md: (...args) => css`
@media (min-width: 768px) {
${css(...args)}
}
`,
lg: (...args) => css`
@media (min-width: 1100px) {
const sizes = {
sm: 500,
md: 768,
lg: 1100
};

export default Object.keys(sizes).reduce((acc, label) => {
const accumulator = acc;
accumulator[label] = (...args) => css`
@media (min-width: ${sizes[label]}px) {
${css(...args)}
}
`,
};
`;
return accumulator;
}, {});

0 comments on commit 0ff209c

Please sign in to comment.