diff --git a/src/components/ui/Form.jsx b/src/components/ui/Form.jsx index 0d671ec..23af7ac 100644 --- a/src/components/ui/Form.jsx +++ b/src/components/ui/Form.jsx @@ -70,6 +70,62 @@ export class Input extends Component { } } +export class LabeledInput extends Component { + static displayName = 'LabeledInput'; + + static propTypes = { + label: PropTypes.oneOfType([ + PropTypes.shape({ + id: PropTypes.string + }), + PropTypes.string + ]).isRequired, + id: PropTypes.string, + icon: PropTypes.string, + skin: PropTypes.oneOf(['dark', 'light']), + color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue']) + }; + + static contextTypes = { + intl: intlShape.isRequired + }; + + render() { + let { label } = this.props; + + let props = Object.assign({}, this.props); + + if (!props.id) { + props.id = uniqueId('input'); + } + + if (label && label.id) { + label = this.context.intl.formatMessage(label); + } + + return ( +