Integrating new form binder

This commit is contained in:
John Lyon-Smith
2018-03-06 07:43:21 -08:00
parent 535fffaf41
commit c1bf470aa0
15 changed files with 93 additions and 54 deletions

View File

@@ -17,15 +17,36 @@ class Box extends Component {
}
render() {
const { children, background, borderTop, borderBottom, borderLeft,
borderRight, border, radius } = this.props
let {
children, background,
borderTop, borderBottom, borderLeft, borderRight,
border, radius } = this.props
const flatten = (border) => {
if (!border) {
return null
}
border.style = border.style || 'solid'
border.width = border.width || 1
border.color = border.color || 'black'
return (border.width.toString() + 'px ' + border.style + ' ' + border.color)
}
if (border) {
borderTop = borderBottom = borderLeft = borderRight = flatten(border)
} else {
borderTop = flatten(borderTop)
borderBottom = flatten(borderBottom)
borderLeft = flatten(borderLeft)
borderRight = flatten(borderRight)
}
return (
<div style={[
{ height: '100%', width: '100%' },
{ height: '100%', width: '100%', borderTop, borderBottom, borderLeft, borderRight },
background && { backgroundColor: background },
radius && { borderRadius: radius },
border ? { border } : { borderTop, borderBottom, borderLeft, borderRight },
]}>
{children}
</div>