Makes input fields easier to click. Closes #173
This commit is contained in:
parent
78a9ac0f4b
commit
f5d1fa7314
@ -1,7 +1,7 @@
|
|||||||
.control {
|
.control {
|
||||||
color: #7c8382;
|
color: #7c8382;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 20px 0;
|
padding: 20px 0 10px 0;
|
||||||
|
|
||||||
& input,
|
& input,
|
||||||
& textarea,
|
& textarea,
|
||||||
@ -9,7 +9,7 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0;
|
padding: 12px 0 10px 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: none;
|
border: none;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
@ -24,7 +24,6 @@
|
|||||||
display: block;
|
display: block;
|
||||||
color: #AAB0AF;
|
color: #AAB0AF;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.labelWithError {
|
.labelWithError {
|
||||||
@ -36,7 +35,7 @@
|
|||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: #FF706F;
|
color: #FF706F;
|
||||||
margin-bottom: 18px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget {
|
.widget {
|
||||||
|
@ -89,6 +89,7 @@ class ControlHOC extends Component {
|
|||||||
onAddAsset,
|
onAddAsset,
|
||||||
onRemoveAsset,
|
onRemoveAsset,
|
||||||
getAsset,
|
getAsset,
|
||||||
|
forID: field.get('name'),
|
||||||
ref: this.processInnerControlRef,
|
ref: this.processInnerControlRef,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ export default class ListControl extends Component {
|
|||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
field: PropTypes.node,
|
field: PropTypes.node,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
getAsset: PropTypes.func.isRequired,
|
getAsset: PropTypes.func.isRequired,
|
||||||
onAddAsset: PropTypes.func.isRequired,
|
onAddAsset: PropTypes.func.isRequired,
|
||||||
onRemoveAsset: PropTypes.func.isRequired,
|
onRemoveAsset: PropTypes.func.isRequired,
|
||||||
@ -162,15 +163,15 @@ export default class ListControl extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderListControl() {
|
renderListControl() {
|
||||||
const { value } = this.props;
|
const { value, forID } = this.props;
|
||||||
return (<div>
|
return (<div id={forID}>
|
||||||
{value && value.map((item, index) => this.renderItem(item, index))}
|
{value && value.map((item, index) => this.renderItem(item, index))}
|
||||||
<div><button className={styles.addButton} onClick={this.handleAdd}>new</button></div>
|
<div><button className={styles.addButton} onClick={this.handleAdd}>new</button></div>
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { field } = this.props;
|
const { field, forID } = this.props;
|
||||||
const { value } = this.state;
|
const { value } = this.state;
|
||||||
|
|
||||||
if (field.get('field') || field.get('fields')) {
|
if (field.get('field') || field.get('fields')) {
|
||||||
@ -179,6 +180,7 @@ export default class ListControl extends Component {
|
|||||||
|
|
||||||
return (<input
|
return (<input
|
||||||
type="text"
|
type="text"
|
||||||
|
id={forID}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
onBlur={this.handleCleanup}
|
onBlur={this.handleCleanup}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
export default class StringControl extends React.Component {
|
export default class StringControl extends React.Component {
|
||||||
handleChange = e => {
|
handleChange = (e) => {
|
||||||
this.props.onChange(e.target.value);
|
this.props.onChange(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <input type="number" value={this.props.value || ''} onChange={this.handleChange}/>;
|
return <input type="number" id={this.props.forID} value={this.props.value || ''} onChange={this.handleChange} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringControl.propTypes = {
|
StringControl.propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ export default class ObjectControl extends Component {
|
|||||||
getAsset: PropTypes.func.isRequired,
|
getAsset: PropTypes.func.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
field: PropTypes.object,
|
field: PropTypes.object,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
controlFor(field) {
|
controlFor(field) {
|
||||||
@ -38,12 +39,12 @@ export default class ObjectControl extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { field } = this.props;
|
const { field, forID } = this.props;
|
||||||
const multiFields = field.get('fields');
|
const multiFields = field.get('fields');
|
||||||
const singleField = field.get('field');
|
const singleField = field.get('field');
|
||||||
|
|
||||||
if (multiFields) {
|
if (multiFields) {
|
||||||
return (<div className={styles.root}>
|
return (<div id={forID} className={styles.root}>
|
||||||
{multiFields.map(field => this.controlFor(field))}
|
{multiFields.map(field => this.controlFor(field))}
|
||||||
</div>);
|
</div>);
|
||||||
} else if (singleField) {
|
} else if (singleField) {
|
||||||
|
@ -15,6 +15,7 @@ function escapeRegexCharacters(str) {
|
|||||||
class RelationControl extends Component {
|
class RelationControl extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
field: PropTypes.node,
|
field: PropTypes.node,
|
||||||
isFetching: PropTypes.node,
|
isFetching: PropTypes.node,
|
||||||
@ -105,12 +106,13 @@ class RelationControl extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { value, isFetching, queryHits } = this.props;
|
const { value, isFetching, forID, queryHits } = this.props;
|
||||||
|
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
value: value || '',
|
value: value || '',
|
||||||
onChange: this.onChange,
|
onChange: this.onChange,
|
||||||
|
id: forID,
|
||||||
};
|
};
|
||||||
|
|
||||||
const suggestions = (queryHits.get) ? queryHits.get(this.controlID, []) : [];
|
const suggestions = (queryHits.get) ? queryHits.get(this.controlID, []) : [];
|
||||||
|
@ -7,7 +7,7 @@ export default class SelectControl extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { field, value } = this.props;
|
const { field, value, forID } = this.props;
|
||||||
const fieldOptions = field.get('options');
|
const fieldOptions = field.get('options');
|
||||||
|
|
||||||
if (!fieldOptions) {
|
if (!fieldOptions) {
|
||||||
@ -21,7 +21,7 @@ export default class SelectControl extends React.Component {
|
|||||||
return option;
|
return option;
|
||||||
});
|
});
|
||||||
|
|
||||||
return (<select value={value || ''} onChange={this.handleChange}>
|
return (<select id={forID} value={value || ''} onChange={this.handleChange}>
|
||||||
{options.map((option, idx) => <option key={idx} value={option.value}>
|
{options.map((option, idx) => <option key={idx} value={option.value}>
|
||||||
{option.label}
|
{option.label}
|
||||||
</option>)}
|
</option>)}
|
||||||
@ -32,6 +32,7 @@ export default class SelectControl extends React.Component {
|
|||||||
SelectControl.propTypes = {
|
SelectControl.propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
field: ImmutablePropTypes.contains({
|
field: ImmutablePropTypes.contains({
|
||||||
options: ImmutablePropTypes.listOf(PropTypes.oneOf([
|
options: ImmutablePropTypes.listOf(PropTypes.oneOf([
|
||||||
PropTypes.string,
|
PropTypes.string,
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
export default class StringControl extends React.Component {
|
export default class StringControl extends React.Component {
|
||||||
handleChange = e => {
|
handleChange = (e) => {
|
||||||
this.props.onChange(e.target.value);
|
this.props.onChange(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <input type="text" value={this.props.value || ''} onChange={this.handleChange}/>;
|
return <input type="text" id={this.props.forID} value={this.props.value || ''} onChange={this.handleChange} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringControl.propTypes = {
|
StringControl.propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
@ -5,27 +5,28 @@ export default class StringControl extends React.Component {
|
|||||||
this.updateHeight();
|
this.updateHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange = e => {
|
handleChange = (e) => {
|
||||||
this.props.onChange(e.target.value);
|
this.props.onChange(e.target.value);
|
||||||
this.updateHeight();
|
this.updateHeight();
|
||||||
};
|
};
|
||||||
|
|
||||||
updateHeight() {
|
updateHeight() {
|
||||||
if (this.element.scrollHeight > this.element.clientHeight) {
|
if (this.element.scrollHeight > this.element.clientHeight) {
|
||||||
this.element.style.height = this.element.scrollHeight + 'px';
|
this.element.style.height = `${ this.element.scrollHeight }px`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRef = ref => {
|
handleRef = (ref) => {
|
||||||
this.element = ref;
|
this.element = ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <textarea ref={this.handleRef} value={this.props.value || ''} onChange={this.handleChange}/>;
|
return <textarea ref={this.handleRef} id={this.props.forID} value={this.props.value || ''} onChange={this.handleChange} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringControl.propTypes = {
|
StringControl.propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
forID: PropTypes.string.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user