insomnia/app/components/Sidebar.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-03-20 04:00:40 +00:00
import React, {PropTypes} from 'react'
2016-03-18 00:36:00 +00:00
const Sidebar = (props) => (
2016-03-18 21:31:45 +00:00
<aside id="sidebar" className="pane">
2016-03-20 04:00:40 +00:00
<header className="pane__header bg-primary">
2016-03-21 05:47:49 +00:00
<h1>
2016-03-20 04:00:40 +00:00
<a href="#" className="pane__header__content">
{props.loading ? <i className="fa fa-refresh fa-spin pull-right"></i> : ''}
Insomnia
</a>
2016-03-21 05:47:49 +00:00
</h1>
2016-03-18 00:36:00 +00:00
</header>
2016-03-21 05:47:49 +00:00
<div className="pane__body grid-v hide-scrollbars">
2016-03-18 21:31:45 +00:00
<ul className="sidebar-items">
2016-03-20 04:00:40 +00:00
<li className="grid">
<div className="form-control col">
<input type="text" placeholder="Filter Requests"/>
</div>
<button className="btn" onClick={(e) => props.addRequest()}>
<i className="fa fa-plus-circle"></i>
</button>
</li>
</ul>
2016-03-21 05:47:49 +00:00
<ul className="sidebar-items row">
2016-03-20 23:20:00 +00:00
{props.requests.map((request) => {
const isActive = request.id === props.activeRequest.id;
2016-03-20 04:00:40 +00:00
return (
<li key={request.id} className={'sidebar-item ' + (isActive ? 'active': '')}>
2016-03-20 23:20:00 +00:00
<a href="#" onClick={() => {props.activateRequest(request.id)}}>{request.name}</a>
2016-03-20 04:00:40 +00:00
</li>
);
2016-03-18 21:31:45 +00:00
})}
</ul>
</div>
2016-03-18 00:36:00 +00:00
</aside>
);
2016-03-20 04:00:40 +00:00
Sidebar.propTypes = {
2016-03-20 04:47:43 +00:00
activateRequest: PropTypes.func.isRequired,
2016-03-20 23:20:00 +00:00
requests: PropTypes.array.isRequired,
activeRequest: PropTypes.object,
2016-03-20 04:00:40 +00:00
loading: PropTypes.bool.isRequired
};
2016-03-18 00:36:00 +00:00
export default Sidebar;