Comparing version 0.6.2 to 0.7.0
@@ -23,3 +23,3 @@ 'use strict'; | ||
arrayOf = _react.PropTypes.arrayOf, | ||
element = _react.PropTypes.element, | ||
node = _react.PropTypes.node, | ||
string = _react.PropTypes.string, | ||
@@ -47,3 +47,3 @@ number = _react.PropTypes.number; | ||
FlexLayout.propTypes = { | ||
children: oneOfType([element, arrayOf(element)]), | ||
children: oneOfType([node, arrayOf(node)]), | ||
sizes: arrayOf(number), | ||
@@ -50,0 +50,0 @@ alignCrossAxis: string, |
@@ -24,3 +24,3 @@ 'use strict'; | ||
var applyLayoutConstraints = function applyLayoutConstraints(children, sizes) { | ||
return _react.Children.toArray(children).map(function (child, index) { | ||
return _react.Children.toArray(children).filter(_react.isValidElement).map(function (child, index) { | ||
return (0, _react.cloneElement)(child, { | ||
@@ -27,0 +27,0 @@ style: Object.assign({}, child.props.style, { |
@@ -19,3 +19,3 @@ 'use strict'; | ||
arrayOf = _react.PropTypes.arrayOf, | ||
element = _react.PropTypes.element, | ||
node = _react.PropTypes.node, | ||
string = _react.PropTypes.string; | ||
@@ -41,3 +41,3 @@ | ||
SpacedLayout.propTypes = { | ||
children: oneOfType([element, arrayOf(element)]), | ||
children: oneOfType([node, arrayOf(node)]), | ||
alignCrossAxis: string, | ||
@@ -44,0 +44,0 @@ container: _containerValidation2.default, |
{ | ||
"name": "layabout", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Simple layout components for React", | ||
@@ -24,4 +24,4 @@ "author": "Dan Mutton", | ||
"lint": "eslint src", | ||
"test-once": "yarn lint && jest", | ||
"test": "jest --watch", | ||
"test": "yarn lint && jest", | ||
"tdd": "jest --watch", | ||
"demo": "start-storybook -p 9009 -c demo", | ||
@@ -28,0 +28,0 @@ "build-demo-docs": "build-storybook -c demo -o docs" |
# Layabout | ||
[](https://circleci.com/gh/yearofthedan/layabout) | ||
 | ||
Low config layout components for React. | ||
@@ -6,0 +5,0 @@ |
@@ -102,2 +102,3 @@ import React from 'react'; | ||
describe('sizes', () => { | ||
@@ -141,3 +142,16 @@ it('gives each child the flexBasis for its position', () => { | ||
}); | ||
it('filters out any non element nodes', () => { | ||
const rendered = shallow( | ||
<FlexLayout sizes={[3, 4, 1, 1, 1]}> | ||
{ false } | ||
{ null } | ||
some text | ||
<div id="1" /> | ||
<div id="2" /> | ||
</FlexLayout>); | ||
expect(rendered.find('#1')).toHaveStyle('flex', '0 0 30%'); | ||
expect(rendered.find('#2')).toHaveStyle('flex', '0 0 40%'); | ||
}); | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ import { PropTypes, createElement } from 'react'; | ||
const { oneOfType, arrayOf, element, string, number } = PropTypes; | ||
const { oneOfType, arrayOf, node, string, number } = PropTypes; | ||
@@ -22,3 +22,3 @@ const FlexLayout = ({ children, sizes, container, alignCrossAxis, direction }) => ( | ||
FlexLayout.propTypes = { | ||
children: oneOfType([element, arrayOf(element)]), | ||
children: oneOfType([node, arrayOf(node)]), | ||
sizes: arrayOf(number), | ||
@@ -25,0 +25,0 @@ alignCrossAxis: string, |
@@ -1,2 +0,2 @@ | ||
import { Children, cloneElement } from 'react'; | ||
import { Children, cloneElement, isValidElement } from 'react'; | ||
@@ -14,2 +14,3 @@ const deriveFlex = (index, sizes, childrenCount = 1) => { | ||
const applyLayoutConstraints = (children, sizes) => Children.toArray(children) | ||
.filter(isValidElement) | ||
.map((child, index) => cloneElement(child, { | ||
@@ -16,0 +17,0 @@ style: { |
@@ -5,3 +5,3 @@ import { PropTypes, createElement } from 'react'; | ||
const { oneOfType, arrayOf, element, string } = PropTypes; | ||
const { oneOfType, arrayOf, node, string } = PropTypes; | ||
@@ -19,3 +19,3 @@ const SpacedLayout = ({ children, container, spacing, alignCrossAxis, direction }) => | ||
SpacedLayout.propTypes = { | ||
children: oneOfType([element, arrayOf(element)]), | ||
children: oneOfType([node, arrayOf(node)]), | ||
alignCrossAxis: string, | ||
@@ -22,0 +22,0 @@ container: validContainer, |
248247
1039
102