lbry-desktop/ui/component/sideBar/view.jsx

109 lines
3.1 KiB
React
Raw Normal View History

2018-03-26 14:32:43 -07:00
// @flow
2019-03-28 12:53:13 -04:00
import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons';
2019-09-26 12:07:11 -04:00
import React from 'react';
2018-03-26 14:32:43 -07:00
import Button from 'component/button';
2019-06-11 14:10:58 -04:00
import Tag from 'component/tag';
2019-07-17 16:49:06 -04:00
import StickyBox from 'react-sticky-box/dist/esnext';
import Spinner from 'component/spinner';
2018-03-26 14:32:43 -07:00
type Props = {
2019-06-11 14:10:58 -04:00
subscriptions: Array<Subscription>,
followedTags: Array<Tag>,
2019-08-21 16:54:44 -04:00
email: ?string,
2019-09-26 12:07:11 -04:00
obscureSideBar: boolean,
uploadCount: number,
2018-03-26 14:32:43 -07:00
};
2019-06-11 14:10:58 -04:00
function SideBar(props: Props) {
const { subscriptions, followedTags, obscureSideBar, uploadCount } = props;
2019-07-17 16:49:06 -04:00
function buildLink(path, label, icon, guide) {
return {
navigate: path ? `$/${path}` : '/',
label,
icon,
guide,
};
}
2019-04-19 17:15:41 -04:00
2019-09-26 12:07:11 -04:00
return obscureSideBar ? (
<StickyBox offsetTop={100} offsetBottom={20}>
<div className="card navigation--placeholder">
<div className="wrap">
<h2>LBRY</h2>
<p>{__('The best decentralized content platform on the web.')}</p>
</div>
</div>
</StickyBox>
) : (
2019-07-23 04:05:51 -04:00
<StickyBox offsetTop={100} offsetBottom={20}>
2019-09-26 12:07:11 -04:00
<nav className="navigation">
<ul className="navigation-links">
{[
{
...buildLink(null, __('Home'), ICONS.HOME),
},
// @if TARGET='app'
{
...buildLink(PAGES.LIBRARY, __('Library'), ICONS.LIBRARY),
},
// @endif
{
...buildLink(PAGES.CHANNELS, __('Channels'), ICONS.CHANNEL),
},
2019-09-26 12:07:11 -04:00
{
...buildLink(
PAGES.PUBLISHED,
uploadCount ? (
<span>
{__('Publishes')}
<Spinner type="small" />
</span>
) : (
__('Publishes')
),
ICONS.PUBLISH
),
2019-09-26 12:07:11 -04:00
},
].map(linkProps => (
<li key={linkProps.navigate}>
2019-09-26 12:07:11 -04:00
<Button {...linkProps} className="navigation-link" activeClass="navigation-link--active" />
</li>
))}
</ul>
2019-08-27 10:43:42 -04:00
2019-09-26 12:07:11 -04:00
<Button
navigate={`/$/${PAGES.FOLLOWING}`}
label={__('Customize')}
2019-12-06 14:42:44 -05:00
icon={ICONS.EDIT}
2019-09-26 12:07:11 -04:00
className="navigation-link"
activeClass="navigation-link--active"
/>
2019-09-27 14:56:15 -04:00
<section className="navigation-links__inline">
<ul className="navigation-links--small tags--vertical">
{followedTags.map(({ name }, key) => (
<li className="navigation-link__wrapper" key={name}>
<Tag navigate={`/$/tags?t${name}`} name={name} />
</li>
))}
</ul>
<ul className="navigation-links--small">
{subscriptions.map(({ uri, channelName }, index) => (
<li key={uri} className="navigation-link__wrapper">
<Button
navigate={uri}
label={channelName}
className="navigation-link"
activeClass="navigation-link--active"
/>
</li>
))}
</ul>
</section>
2019-09-26 12:07:11 -04:00
</nav>
2019-07-17 16:49:06 -04:00
</StickyBox>
2019-06-11 14:10:58 -04:00
);
}
2018-03-26 14:32:43 -07:00
export default SideBar;