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

82 lines
2.3 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';
2018-03-26 23:32:43 +02:00
import * as React from 'react';
import Button from 'component/button';
2019-06-11 20:10:58 +02:00
import Tag from 'component/tag';
2018-03-26 23:32:43 +02:00
type Props = {
2019-06-11 20:10:58 +02:00
subscriptions: Array<Subscription>,
followedTags: Array<Tag>,
2018-03-26 23:32:43 +02:00
};
2019-06-11 20:10:58 +02:00
function SideBar(props: Props) {
const { subscriptions, followedTags } = props;
const buildLink = (path, label, icon, guide) => ({
navigate: path ? `$/${path}` : '/',
label,
icon,
guide,
});
2019-06-11 20:10:58 +02:00
const renderLink = linkProps => (
2019-06-17 22:32:38 +02:00
<li key={linkProps.label}>
<Button {...linkProps} className="navigation__link" activeClass="navigation__link--active" />
</li>
2019-06-11 20:10:58 +02:00
);
2019-04-19 23:15:41 +02:00
2019-06-11 20:10:58 +02:00
return (
<div className="navigation-wrapper">
<nav className="navigation">
2019-03-28 17:53:13 +01:00
<ul className="navigation__links">
{[
{
2019-06-11 20:10:58 +02:00
...buildLink(null, __('Home'), ICONS.HOME),
2019-03-28 17:53:13 +01:00
},
{
...buildLink(PAGES.FOLLOWING, __('Following'), ICONS.SUBSCRIPTION),
2019-03-28 17:53:13 +01:00
},
2019-04-01 01:04:01 +02:00
{
...buildLink(PAGES.LIBRARY, __('Library'), ICONS.LIBRARY),
2019-04-01 01:04:01 +02:00
},
{
...buildLink(PAGES.PUBLISHED, __('Publishes'), ICONS.PUBLISHED),
2019-04-01 01:04:01 +02:00
},
2019-03-28 17:53:13 +01:00
].map(renderLink)}
2019-06-17 22:32:38 +02:00
<li>
<Button
navigate="/$/following/edit"
2019-06-17 22:32:38 +02:00
icon={ICONS.EDIT}
className="navigation__link"
activeClass="navigation__link--active"
label={__('Edit')}
2019-06-17 22:32:38 +02:00
/>
</li>
</ul>
<ul className="navigation__links tags--vertical">
2019-06-11 20:10:58 +02:00
{followedTags.map(({ name }, key) => (
2019-06-17 22:32:38 +02:00
<li className="navigation__link--indented" key={name}>
2019-06-11 20:10:58 +02:00
<Tag navigate={`/$/tags?t${name}`} name={name} />
</li>
))}
2019-03-28 17:53:13 +01:00
</ul>
2019-06-11 20:10:58 +02:00
<ul className="navigation__links--small">
2019-06-17 22:32:38 +02:00
{subscriptions.map(({ uri, channelName }, index) => (
<li key={uri} className="navigation__link--indented">
<Button
navigate={uri}
label={channelName}
className="navigation__link"
activeClass="navigation__link--active"
/>
</li>
2019-06-11 20:10:58 +02:00
))}
2019-03-28 17:53:13 +01:00
</ul>
</nav>
2019-06-11 20:10:58 +02:00
</div>
);
}
2018-03-26 23:32:43 +02:00
export default SideBar;