Comparing version 0.7.0 to 0.7.1
@@ -24,6 +24,7 @@ 'use strict'; | ||
var applyLayoutConstraints = function applyLayoutConstraints(children, sizes) { | ||
return _react.Children.toArray(children).filter(_react.isValidElement).map(function (child, index) { | ||
return _react.Children.toArray(children).filter(_react.isValidElement).map(function (child, index, _ref) { | ||
var length = _ref.length; | ||
return (0, _react.cloneElement)(child, { | ||
style: Object.assign({}, child.props.style, { | ||
flex: '0 0 ' + deriveFlex(index, sizes, children.length) + '%' | ||
flex: '0 0 ' + deriveFlex(index, sizes, length) + '%' | ||
}), | ||
@@ -30,0 +31,0 @@ key: index |
{ | ||
"name": "layabout", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Simple layout components for React", | ||
@@ -5,0 +5,0 @@ "author": "Dan Mutton", |
@@ -102,3 +102,2 @@ import React from 'react'; | ||
describe('sizes', () => { | ||
@@ -145,3 +144,3 @@ it('gives each child the flexBasis for its position', () => { | ||
const rendered = shallow( | ||
<FlexLayout sizes={[3, 4, 1, 1, 1]}> | ||
<FlexLayout> | ||
{ false } | ||
@@ -153,6 +152,6 @@ { null } | ||
</FlexLayout>); | ||
expect(rendered.find('#1')).toHaveStyle('flex', '0 0 30%'); | ||
expect(rendered.find('#2')).toHaveStyle('flex', '0 0 40%'); | ||
expect(rendered.find('#1')).toHaveStyle('flex', '0 0 50%'); | ||
expect(rendered.find('#2')).toHaveStyle('flex', '0 0 50%'); | ||
}); | ||
}); | ||
}); |
@@ -15,6 +15,6 @@ import { Children, cloneElement, isValidElement } from 'react'; | ||
.filter(isValidElement) | ||
.map((child, index) => cloneElement(child, { | ||
.map((child, index, { length }) => cloneElement(child, { | ||
style: { | ||
...child.props.style, | ||
flex: `0 0 ${deriveFlex(index, sizes, children.length)}%`, | ||
flex: `0 0 ${deriveFlex(index, sizes, length)}%`, | ||
}, | ||
@@ -21,0 +21,0 @@ key: index, |
248252
1040