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';
|
|
|
|
import classnames from 'classnames';
|
2019-01-27 01:23:47 +01:00
|
|
|
import Tooltip from 'component/common/tooltip';
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
type Props = {
|
2018-10-19 22:38:07 +02:00
|
|
|
unreadSubscriptionTotal: number,
|
2019-04-19 23:15:41 +02:00
|
|
|
shouldShowInviteGuide: string,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2019-01-27 01:23:47 +01:00
|
|
|
class SideBar extends React.PureComponent<Props> {
|
2019-03-28 17:53:13 +01:00
|
|
|
render() {
|
2019-04-19 23:15:41 +02:00
|
|
|
const { unreadSubscriptionTotal, shouldShowInviteGuide } = this.props;
|
|
|
|
const buildLink = (path, label, icon, guide) => ({
|
2019-03-28 17:53:13 +01:00
|
|
|
navigate: path ? `$/${path}` : '/',
|
|
|
|
label,
|
|
|
|
icon,
|
2019-04-19 23:15:41 +02:00
|
|
|
guide,
|
2019-03-28 17:53:13 +01:00
|
|
|
});
|
2018-12-19 06:44:53 +01:00
|
|
|
|
2019-04-19 23:15:41 +02:00
|
|
|
const renderLink = (linkProps, index) => {
|
|
|
|
const { guide } = linkProps;
|
|
|
|
|
|
|
|
const inner = (
|
2019-03-28 17:53:13 +01:00
|
|
|
<Button
|
|
|
|
{...linkProps}
|
2019-04-19 23:15:41 +02:00
|
|
|
className={classnames('navigation__link', {
|
|
|
|
'navigation__link--guide': guide,
|
|
|
|
})}
|
2019-03-28 17:53:13 +01:00
|
|
|
activeClass="navigation__link--active"
|
|
|
|
/>
|
2019-04-19 23:15:41 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<li key={index}>
|
|
|
|
{guide ? (
|
|
|
|
<Tooltip key={guide} alwaysVisible direction="right" body={guide}>
|
|
|
|
{inner}
|
|
|
|
</Tooltip>
|
|
|
|
) : (
|
|
|
|
inner
|
|
|
|
)}
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
};
|
2018-12-19 06:44:53 +01:00
|
|
|
|
2019-01-27 01:23:47 +01:00
|
|
|
return (
|
|
|
|
<nav className="navigation">
|
2019-03-28 17:53:13 +01:00
|
|
|
<ul className="navigation__links">
|
|
|
|
{[
|
|
|
|
{
|
2019-04-01 01:04:01 +02:00
|
|
|
...buildLink(null, __('Discover'), ICONS.DISCOVER),
|
2019-03-28 17:53:13 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
...buildLink(
|
|
|
|
PAGES.SUBSCRIPTIONS,
|
2019-05-07 23:38:29 +02:00
|
|
|
`${__('Subscriptions')} ${unreadSubscriptionTotal > 0 ? '(' + unreadSubscriptionTotal + ')' : ''}`,
|
2019-03-28 17:53:13 +01:00
|
|
|
ICONS.SUBSCRIPTION
|
|
|
|
),
|
|
|
|
},
|
2019-04-01 01:04:01 +02:00
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.PUBLISHED, __('Publishes'), ICONS.PUBLISHED),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.HISTORY, __('Library'), ICONS.DOWNLOAD),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
2019-03-28 17:53:13 +01:00
|
|
|
].map(renderLink)}
|
|
|
|
</ul>
|
2019-04-01 01:04:01 +02:00
|
|
|
<div className="navigation__link navigation__link--title">Account</div>
|
2019-03-28 17:53:13 +01:00
|
|
|
|
|
|
|
<ul className="navigation__links">
|
|
|
|
{[
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.ACCOUNT, __('Overview'), ICONS.ACCOUNT),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.INVITE, __('Invite'), ICONS.INVITE, shouldShowInviteGuide && __('Check this out!')),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.REWARDS, __('Rewards'), ICONS.FEATURED),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.SEND, __('Send & Recieve'), ICONS.SEND),
|
2019-03-28 17:53:13 +01:00
|
|
|
},
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.TRANSACTIONS, __('Transactions'), ICONS.TRANSACTIONS),
|
2019-03-28 17:53:13 +01:00
|
|
|
},
|
2019-04-01 01:04:01 +02:00
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.SETTINGS, __('Settings'), ICONS.SETTINGS),
|
2019-04-01 01:04:01 +02:00
|
|
|
},
|
2019-03-28 17:53:13 +01:00
|
|
|
].map(renderLink)}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul className="navigation__links navigation__links--bottom">
|
|
|
|
{[
|
|
|
|
{
|
2019-05-13 08:05:38 +02:00
|
|
|
...buildLink(PAGES.HELP, __('Help'), ICONS.HELP),
|
2019-03-28 17:53:13 +01:00
|
|
|
},
|
|
|
|
].map(renderLink)}
|
|
|
|
</ul>
|
2019-01-27 01:23:47 +01:00
|
|
|
</nav>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
export default SideBar;
|