Restyle to use border box

This commit is contained in:
Lukas Martinelli
2016-12-31 12:17:02 +01:00
parent e7709dae15
commit 0eb00312f4
7 changed files with 74 additions and 61 deletions

View File

@@ -18,8 +18,8 @@ class ArrayInput extends React.Component {
render() {
const values = this.props.value || this.props.default || []
const commonStyle = {
width: '15%',
marginRight: margins[0],
width: '49%',
marginRight: '1%',
}
const inputs = values.map((v, i) => {
if(this.props.type === 'number') {
@@ -28,7 +28,7 @@ class ArrayInput extends React.Component {
return <StringInput key={i} value={v} style={commonStyle} />
})
return <div style={{display: 'inline-block', width: '51%'}}>
return <div style={{display: 'inline-block', width: '50%'}}>
{inputs}
</div>
}

View File

@@ -8,7 +8,8 @@ class AutocompleteInput extends React.Component {
static propTypes = {
value: React.PropTypes.string,
options: React.PropTypes.array,
style: React.PropTypes.object,
wrapperStyle: React.PropTypes.object,
inputStyle: React.PropTypes.object,
onChange: React.PropTypes.func,
}
@@ -28,11 +29,15 @@ class AutocompleteInput extends React.Component {
background: colors.gray,
zIndex: 3,
}}
wrapperStyle={{
display: 'inline-block',
...this.props.wrapperStyle
}}
inputProps={{
style: {
...input.input,
width: null,
...this.props.style,
width: '100%',
...this.props.inputStyle,
}
}}
value={this.props.value}

View File

@@ -15,15 +15,30 @@ class InputBlock extends React.Component {
return this.props.onChange(value === "" ? null: value)
}
renderChildren() {
return React.Children.map(this.props.children, child => {
return React.cloneElement(child, {
style: {
...child.props.style,
width: '50%',
}
})
})
}
render() {
return <div style={{
display: 'block',
marginTop: margins[2],
marginBottom: margins[2],
...input.property,
...this.props.style,
}}>
<label style={input.label}>{this.props.label}</label>
{this.props.children}
<label
style={{
...input.label,
width: '50%',
}}>
{this.props.label}
</label>
{this.renderChildren()}
</div>
}
}