redesign for fileSelector component

This commit is contained in:
btzr-io 2017-10-02 21:04:21 -06:00
parent 28f4b98e20
commit 59778808e3
2 changed files with 25 additions and 3 deletions

View file

@ -12,6 +12,11 @@ class FileSelector extends React.PureComponent {
type: "file", type: "file",
}; };
constructor(props) {
super(props);
this._inputElem = null;
}
componentWillMount() { componentWillMount() {
this.setState({ this.setState({
path: this.props.initPath || null, path: this.props.initPath || null,
@ -47,7 +52,7 @@ class FileSelector extends React.PureComponent {
<div className="file-selector"> <div className="file-selector">
<button <button
type="button" type="button"
className="file-selector__choose-button" className="button-block button-alt file-selector__choose-button"
onClick={() => this.handleButtonClick()} onClick={() => this.handleButtonClick()}
> >
{this.props.type == "file" {this.props.type == "file"
@ -56,7 +61,18 @@ class FileSelector extends React.PureComponent {
</button> </button>
{" "} {" "}
<span className="file-selector__path"> <span className="file-selector__path">
{this.state.path ? this.state.path : __("No File Chosen")} <input
className="input-copyable"
type="text"
ref={input => {
this._inputElem = input;
}}
onFocus={() => {
this._inputElem.select();
}}
readOnly="readonly"
value={this.state.path || __("No File Chosen")}
/>
</span> </span>
</div> </div>
); );

View file

@ -1,5 +1,11 @@
.file-selector {
display: flex;
}
.file-selector__choose-button { .file-selector__choose-button {
font-size: 13px; font-family: inherit;
margin-right: 16px;
padding: 0 16px;
} }
.file-selector__path { .file-selector__path {