Skip to content

allow custom child elements #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var FileInput = React.createClass({
parent: {
position: 'relative'
},
// "invisible" above the text
file: {
position: 'absolute',
top: 0,
Expand All @@ -32,6 +33,7 @@ var FileInput = React.createClass({
},

render: function() {

return React.DOM.div({
style: this.state.styles.parent
},
Expand All @@ -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',
Expand All @@ -58,7 +60,8 @@ var FileInput = React.createClass({
placeholder: this.props.placeholder,
disabled: this.props.disabled,
style: this.state.styles.text
}));
})
);
}
});

Expand Down