Label no longer part of field itself

This commit is contained in:
Lukas Martinelli 2016-12-19 16:30:48 +01:00
parent cfd048984b
commit f9f7be1cad
6 changed files with 67 additions and 68 deletions

View file

@ -11,9 +11,7 @@ class BooleanField extends React.Component {
} }
render() { render() {
return <div style={inputStyle.property}> return <input
<label style={inputStyle.label}>{this.props.name}</label>
<input
type="checkbox" type="checkbox"
style={{ style={{
...inputStyle.checkbox, ...inputStyle.checkbox,
@ -24,7 +22,6 @@ class BooleanField extends React.Component {
checked={this.props.value} checked={this.props.value}
> >
</input> </input>
</div>
} }
} }

View file

@ -33,7 +33,8 @@ class ColorField extends React.Component {
render() { render() {
const picker = <div style={{ const picker = <div style={{
position: 'absolute', position: 'absolute',
left: 287 left: 163,
top: 0,
}}> }}>
<ChromePicker <ChromePicker
color={this.props.value ? Color(this.props.value).object() : null} color={this.props.value ? Color(this.props.value).object() : null}
@ -51,9 +52,12 @@ class ColorField extends React.Component {
}} /> }} />
</div> </div>
return <div style={{...inputStyle.property, position: 'relative'}}> return <div style={{
...inputStyle.property,
position: 'relative',
display: 'inline',
}}>
{this.state.pickerOpened && picker} {this.state.pickerOpened && picker}
<label style={inputStyle.label}>{this.props.name}</label>
<input <input
onClick={this.togglePicker.bind(this)} onClick={this.togglePicker.bind(this)}
style={{ style={{

View file

@ -20,9 +20,7 @@ class EnumField extends React.Component {
return <option key={val} value={val}>{val}</option> return <option key={val} value={val}>{val}</option>
}) })
return <div style={inputStyle.property}> return <select
<label style={inputStyle.label}>{this.props.name}</label>
<select
style={{ style={{
...inputStyle.select, ...inputStyle.select,
...this.props.style ...this.props.style
@ -32,7 +30,6 @@ class EnumField extends React.Component {
> >
{options} {options}
</select> </select>
</div>
} }
} }

View file

@ -25,9 +25,7 @@ class NumberField extends React.Component {
} }
render() { render() {
return <div style={inputStyle.property}> return <input
<label style={inputStyle.label}>{this.props.name}</label>
<input
style={{ style={{
...inputStyle.input, ...inputStyle.input,
...this.props.style ...this.props.style
@ -38,7 +36,6 @@ class NumberField extends React.Component {
value={this.props.value} value={this.props.value}
onChange={this.onChange.bind(this)} onChange={this.onChange.bind(this)}
/> />
</div>
} }
} }

View file

@ -36,24 +36,29 @@ class ZoomSpecField extends React.Component {
} }
render() { render() {
const label = <label style={inputStyle.label}>
{labelFromFieldName(this.props.fieldName)}
</label>
if(isZoomField(this.props.value)) { if(isZoomField(this.props.value)) {
const zoomFields = this.props.value.get('stops').map(stop => { const zoomFields = this.props.value.get('stops').map(stop => {
const zoomLevel = stop.get(0) const zoomLevel = stop.get(0)
const value = stop.get(1) const value = stop.get(1)
return <div key={zoomLevel}> return <div style={inputStyle.property} key={zoomLevel}>
<b><span style={inputStyle.label}>Zoom Level {zoomLevel}</span></b> {label}
<SpecField {...this.props} <SpecField {...this.props}
value={value} value={value}
style={{ style={{
width: '20%' width: '33%'
}} }}
/> />
<input <input
style={{ style={{
...inputStyle.input, ...inputStyle.input,
width: '10%' width: '10%',
marginLeft: theme.scale[0],
}} }}
type="number" type="number"
value={zoomLevel} value={zoomLevel}
@ -71,7 +76,10 @@ class ZoomSpecField extends React.Component {
{zoomFields} {zoomFields}
</div> </div>
} else { } else {
return <SpecField {...this.props} /> return <div style={inputStyle.property}>
{label}
<SpecField {...this.props} />
</div>
} }
} }
} }
@ -104,13 +112,12 @@ class SpecField extends React.Component {
} }
render() { render() {
const label = labelFromFieldName(this.props.fieldName)
switch(this.props.fieldSpec.type) { switch(this.props.fieldSpec.type) {
case 'number': return ( case 'number': return (
<NumberField <NumberField
onChange={this.onValueChanged.bind(this, this.props.fieldName)} onChange={this.onValueChanged.bind(this, this.props.fieldName)}
value={this.props.value} value={this.props.value}
name={label} name={this.props.fieldName}
default={this.props.fieldSpec.default} default={this.props.fieldSpec.default}
min={this.props.fieldSpec.min} min={this.props.fieldSpec.min}
max={this.props.fieldSpec.max} max={this.props.fieldSpec.max}
@ -123,7 +130,7 @@ class SpecField extends React.Component {
<EnumField <EnumField
onChange={this.onValueChanged.bind(this, this.props.fieldName)} onChange={this.onValueChanged.bind(this, this.props.fieldName)}
value={this.props.value} value={this.props.value}
name={label} name={this.props.fieldName}
allowedValues={Object.keys(this.props.fieldSpec.values)} allowedValues={Object.keys(this.props.fieldSpec.values)}
doc={this.props.fieldSpec.doc} doc={this.props.fieldSpec.doc}
style={this.props.style} style={this.props.style}
@ -133,7 +140,7 @@ class SpecField extends React.Component {
<StringField <StringField
onChange={this.onValueChanged.bind(this, this.props.fieldName)} onChange={this.onValueChanged.bind(this, this.props.fieldName)}
value={this.props.value} value={this.props.value}
name={label} name={this.props.fieldName}
doc={this.props.fieldSpec.doc} doc={this.props.fieldSpec.doc}
style={this.props.style} style={this.props.style}
/> />
@ -142,7 +149,7 @@ class SpecField extends React.Component {
<ColorField <ColorField
onChange={this.onValueChanged.bind(this, this.props.fieldName)} onChange={this.onValueChanged.bind(this, this.props.fieldName)}
value={this.props.value} value={this.props.value}
name={label} name={this.props.fieldName}
doc={this.props.fieldSpec.doc} doc={this.props.fieldSpec.doc}
style={this.props.style} style={this.props.style}
/> />
@ -151,7 +158,7 @@ class SpecField extends React.Component {
<BooleanField <BooleanField
onChange={this.onValueChanged.bind(this, this.props.fieldName)} onChange={this.onValueChanged.bind(this, this.props.fieldName)}
value={this.props.value} value={this.props.value}
name={label} name={this.props.fieldName}
doc={this.props.fieldSpec.doc} doc={this.props.fieldSpec.doc}
style={this.props.style} style={this.props.style}
/> />

View file

@ -18,9 +18,7 @@ class StringField extends React.Component {
} }
render() { render() {
return <div style={inputStyle.property}> return <input
<label style={inputStyle.label}>{this.props.name}</label>
<input
style={{ style={{
...inputStyle.input, ...inputStyle.input,
...this.props.style ...this.props.style
@ -30,7 +28,6 @@ class StringField extends React.Component {
value={this.props.value ? this.props.value : ""} value={this.props.value ? this.props.value : ""}
onChange={this.onChange.bind(this)} onChange={this.onChange.bind(this)}
/> />
</div>
} }
} }