insomnia/app/components/UrlInput.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-03-20 23:20:00 +00:00
import React, {Component, PropTypes} from 'react'
2016-03-22 05:01:58 +00:00
import Input from './base/Input';
import Dropdown from './base/Dropdown';
2016-03-21 05:47:49 +00:00
import {METHODS} from '../constants/global';
2016-03-20 23:20:00 +00:00
class UrlInput extends Component {
render () {
2016-03-21 05:47:49 +00:00
const {onUrlChange, onMethodChange, urlValue, method} = this.props;
2016-03-20 23:20:00 +00:00
return (
2016-03-21 05:47:49 +00:00
<div className="grid form-control form-control--left form-control--right">
<Dropdown>
<button className="btn txt-lg">
{method}&nbsp;&nbsp;<i className="fa fa-caret-down"></i>
</button>
<ul className="bg-super-light">
{METHODS.map((method) => (
<li key={method}>
<button onClick={onMethodChange.bind(null, method)}>
2016-03-21 05:47:49 +00:00
{method}
</button>
</li>
))}
</ul>
</Dropdown>
2016-03-20 23:20:00 +00:00
<Input type="text"
2016-03-21 05:47:49 +00:00
className="txt-lg"
2016-03-20 23:20:00 +00:00
placeholder="https://google.com"
initialValue={urlValue}
onChange={onUrlChange}/>
2016-03-21 05:47:49 +00:00
<button className="btn">
2016-03-20 23:20:00 +00:00
<i className="fa fa-repeat txt-xl"></i>
</button>
</div>
)
}
}
UrlInput.propTypes = {
onUrlChange: PropTypes.func.isRequired,
2016-03-20 23:27:46 +00:00
onMethodChange: PropTypes.func.isRequired,
urlValue: PropTypes.string.isRequired,
method: PropTypes.string.isRequired
2016-03-20 23:20:00 +00:00
};
export default UrlInput;