2016-07-06 19:09:05 +00:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-07-08 18:57:22 +00:00
|
|
|
import classNames from 'classnames';
|
2016-07-06 19:09:05 +00:00
|
|
|
|
|
|
|
function Sidebar(props) {
|
|
|
|
return (
|
|
|
|
<section className="sidebar">
|
|
|
|
<ul className="sidebar__file-list">
|
2016-07-08 18:57:22 +00:00
|
|
|
{props.files.map(file => {
|
|
|
|
let itemClass = classNames({
|
|
|
|
'sidebar__file-item': true,
|
|
|
|
'sidebar__file-item--selected': file.id === props.selectedFile.id
|
|
|
|
});
|
|
|
|
return (
|
2016-07-12 19:11:45 +00:00
|
|
|
<li
|
|
|
|
className={itemClass}
|
|
|
|
key={file.id}
|
|
|
|
>
|
2016-07-12 16:25:48 +00:00
|
|
|
<a
|
|
|
|
onClick={() => props.setSelectedFile(file.id)}
|
2016-07-12 19:11:45 +00:00
|
|
|
>{file.name}</a>
|
2016-07-12 16:25:48 +00:00
|
|
|
</li>
|
2016-07-08 18:57:22 +00:00
|
|
|
);
|
|
|
|
})}
|
2016-07-06 19:09:05 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sidebar.propTypes = {
|
2016-07-08 18:57:22 +00:00
|
|
|
files: PropTypes.array.isRequired,
|
|
|
|
selectedFile: PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired
|
2016-07-08 19:58:49 +00:00
|
|
|
}),
|
|
|
|
setSelectedFile: PropTypes.func.isRequired
|
2016-07-06 19:09:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Sidebar;
|