2016-07-06 21:09:05 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-07-08 20:57:22 +02:00
|
|
|
import classNames from 'classnames';
|
2016-07-14 18:47:54 +02:00
|
|
|
import InlineSVG from 'react-inlinesvg';
|
|
|
|
const rightArrowUrl = require('../../../images/right-arrow.svg');
|
|
|
|
const leftArrowUrl = require('../../../images/left-arrow.svg');
|
2016-07-06 21:09:05 +02:00
|
|
|
|
|
|
|
function Sidebar(props) {
|
2016-07-14 18:47:54 +02:00
|
|
|
const sidebarClass = classNames({
|
|
|
|
sidebar: true,
|
|
|
|
'sidebar--contracted': !props.isExpanded
|
|
|
|
});
|
|
|
|
|
2016-07-06 21:09:05 +02:00
|
|
|
return (
|
2016-07-14 18:47:54 +02:00
|
|
|
<section className={sidebarClass}>
|
2016-07-13 22:13:28 +02:00
|
|
|
<div className="sidebar__header">
|
|
|
|
<h3 className="sidebar__title">Sketch Files</h3>
|
2016-07-14 18:47:54 +02:00
|
|
|
<div className="sidebar__icons">
|
|
|
|
<a
|
|
|
|
className="sidebar__add"
|
|
|
|
onClick={props.newFile}
|
|
|
|
>
|
|
|
|
+
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
className="sidebar__contract"
|
|
|
|
onClick={props.collapseSidebar}
|
|
|
|
>
|
|
|
|
<InlineSVG src={leftArrowUrl} />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
className="sidebar__expand"
|
|
|
|
onClick={props.expandSidebar}
|
|
|
|
>
|
|
|
|
<InlineSVG src={rightArrowUrl} />
|
|
|
|
</a>
|
|
|
|
</div>
|
2016-07-13 22:13:28 +02:00
|
|
|
</div>
|
2016-07-06 21:09:05 +02:00
|
|
|
<ul className="sidebar__file-list">
|
2016-07-08 20:57:22 +02: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 21:11:45 +02:00
|
|
|
<li
|
|
|
|
className={itemClass}
|
|
|
|
key={file.id}
|
|
|
|
>
|
2016-07-12 18:25:48 +02:00
|
|
|
<a
|
|
|
|
onClick={() => props.setSelectedFile(file.id)}
|
2016-07-12 21:11:45 +02:00
|
|
|
>{file.name}</a>
|
2016-07-12 18:25:48 +02:00
|
|
|
</li>
|
2016-07-08 20:57:22 +02:00
|
|
|
);
|
|
|
|
})}
|
2016-07-06 21:09:05 +02:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sidebar.propTypes = {
|
2016-07-08 20:57:22 +02:00
|
|
|
files: PropTypes.array.isRequired,
|
|
|
|
selectedFile: PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired
|
2016-07-08 21:58:49 +02:00
|
|
|
}),
|
|
|
|
setSelectedFile: PropTypes.func.isRequired
|
2016-07-06 21:09:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Sidebar;
|