2016-11-22 21:19:08 +01:00
|
|
|
import lbry from '../lbry.js';
|
|
|
|
import React from 'react';
|
|
|
|
import {Link} from './link.js';
|
|
|
|
|
2016-08-07 23:05:04 +02:00
|
|
|
var DrawerItem = React.createClass({
|
2016-11-11 12:36:02 +01:00
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
subPages: [],
|
|
|
|
};
|
|
|
|
},
|
2016-08-07 23:05:04 +02:00
|
|
|
render: function() {
|
2016-11-11 12:36:02 +01:00
|
|
|
var isSelected = (this.props.viewingPage == this.props.href.substr(2) ||
|
|
|
|
this.props.subPages.indexOf(this.props.viewingPage) != -1);
|
2016-08-08 00:13:17 +02:00
|
|
|
return <Link {...this.props} className={ 'drawer-item ' + (isSelected ? 'drawer-item-selected' : '') } />
|
2016-08-07 23:05:04 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var drawerImageStyle = { //@TODO: remove this, img should be properly scaled once size is settled
|
|
|
|
height: '36px'
|
|
|
|
};
|
|
|
|
|
2016-08-07 22:10:44 +02:00
|
|
|
var Drawer = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
balance: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
|
|
lbry.getBalance(function(balance) {
|
|
|
|
this.setState({
|
|
|
|
balance: balance
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
render: function() {
|
2016-08-08 02:57:12 +02:00
|
|
|
var isLinux = false && /linux/i.test(navigator.userAgent); // @TODO: find a way to use getVersionInfo() here without messy state management
|
2016-08-07 22:10:44 +02:00
|
|
|
return (
|
|
|
|
<nav id="drawer">
|
|
|
|
<div id="drawer-handle">
|
2016-08-08 00:13:17 +02:00
|
|
|
<Link title="Close" onClick={this.props.onCloseDrawer} icon="icon-bars" className="close-drawer-link"/>
|
2016-08-07 23:05:04 +02:00
|
|
|
<a href="/"><img src="./img/lbry-dark-1600x528.png" style={drawerImageStyle}/></a>
|
2016-08-07 22:10:44 +02:00
|
|
|
</div>
|
2016-08-08 02:57:12 +02:00
|
|
|
<DrawerItem href='/?discover' viewingPage={this.props.viewingPage} label="Discover" icon="icon-search" />
|
2016-08-08 00:13:17 +02:00
|
|
|
<DrawerItem href='/?publish' viewingPage={this.props.viewingPage} label="Publish" icon="icon-upload" />
|
2016-11-11 12:36:02 +01:00
|
|
|
<DrawerItem href='/?downloaded' subPages={['published']} viewingPage={this.props.viewingPage} label="My Files" icon='icon-cloud-download' />
|
|
|
|
<DrawerItem href="/?wallet" subPages={['send', 'receive', 'claim', 'referral']} viewingPage={this.props.viewingPage} label="My Wallet" badge={lbry.formatCredits(this.state.balance) } icon="icon-bank" />
|
2016-08-08 00:13:17 +02:00
|
|
|
<DrawerItem href='/?settings' viewingPage={this.props.viewingPage} label="Settings" icon='icon-gear' />
|
|
|
|
<DrawerItem href='/?help' viewingPage={this.props.viewingPage} label="Help" icon='icon-question-circle' />
|
2016-08-08 02:57:12 +02:00
|
|
|
{isLinux ? <Link href="/?start" icon="icon-close" className="close-lbry-link" /> : null}
|
2016-08-07 22:10:44 +02:00
|
|
|
</nav>
|
|
|
|
);
|
|
|
|
}
|
2016-11-22 21:19:08 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
export default Drawer;
|