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

95 lines
2.9 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
2019-03-28 17:53:13 +01:00
import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons';
2019-08-27 16:43:42 +02:00
import React, { Fragment } from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
2019-06-11 20:10:58 +02:00
import Tag from 'component/tag';
2019-07-17 22:49:06 +02:00
import StickyBox from 'react-sticky-box/dist/esnext';
2018-03-26 23:32:43 +02:00
type Props = {
2019-06-11 20:10:58 +02:00
subscriptions: Array<Subscription>,
followedTags: Array<Tag>,
2019-08-21 22:54:44 +02:00
email: ?string,
2018-03-26 23:32:43 +02:00
};
2019-06-11 20:10:58 +02:00
function SideBar(props: Props) {
2019-08-21 22:54:44 +02:00
const { subscriptions, followedTags, email } = props;
2019-08-27 16:43:42 +02:00
const showSideBar = IS_WEB ? Boolean(email) : true;
2019-07-17 22:49:06 +02:00
function buildLink(path, label, icon, guide) {
return {
navigate: path ? `$/${path}` : '/',
label,
icon,
guide,
};
}
2019-04-19 23:15:41 +02:00
2019-06-11 20:10:58 +02:00
return (
2019-07-23 10:05:51 +02:00
<StickyBox offsetTop={100} offsetBottom={20}>
2019-08-27 16:43:42 +02:00
{showSideBar ? (
2019-08-21 22:54:44 +02: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.PUBLISHED, __('Publishes'), ICONS.PUBLISH),
},
].map(linkProps => (
<li key={linkProps.label}>
<Button {...linkProps} className="navigation-link" activeClass="navigation-link--active" />
</li>
))}
</ul>
2019-08-27 16:43:42 +02:00
{email ? (
<Fragment>
<Button
navigate={`/$/${PAGES.FOLLOWING}`}
label={__('Customize')}
icon={ICONS.EDIT}
className="navigation-link"
activeClass="navigation-link--active"
/>
<ul className="navigation-links 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>
</Fragment>
) : (
<div className="navigation--placeholder" style={{ height: '20vh', marginTop: '1rem', padding: '1rem' }}>
Something about logging up to customize here
</div>
)}
2019-08-21 22:54:44 +02:00
</nav>
) : (
<div className="navigation--placeholder" />
)}
2019-07-17 22:49:06 +02:00
</StickyBox>
2019-06-11 20:10:58 +02:00
);
}
2018-03-26 23:32:43 +02:00
export default SideBar;