From cc745c799d7da8661db32415b246e287f7ca4c8b Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Mon, 9 Nov 2015 18:07:11 -0500 Subject: [PATCH] allow custom child elements also add a comment for anyone unfamiliar with the input style --- lib/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 048fcf3..4196f81 100644 --- a/lib/index.js +++ b/lib/index.js @@ -8,6 +8,7 @@ var FileInput = React.createClass({ parent: { position: 'relative' }, + // "invisible" above the text file: { position: 'absolute', top: 0, @@ -32,6 +33,7 @@ var FileInput = React.createClass({ }, render: function() { + return React.DOM.div({ style: this.state.styles.parent }, @@ -47,8 +49,8 @@ var FileInput = React.createClass({ style: this.state.styles.file }), - // Emulated file input - React.DOM.input({ + // Emulated file input for when there are no children + this.props.children || React.DOM.input({ type: 'text', tabIndex: -1, name: this.props.name + '_filename', @@ -58,7 +60,8 @@ var FileInput = React.createClass({ placeholder: this.props.placeholder, disabled: this.props.disabled, style: this.state.styles.text - })); + }) + ); } });