2018-03-26 14:32:43 -07:00
|
|
|
// @flow
|
2020-08-10 16:47:39 -04:00
|
|
|
import type { Node } from 'react';
|
2019-03-28 12:53:13 -04:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import * as ICONS from 'constants/icons';
|
2021-08-31 15:05:42 +08:00
|
|
|
import * as KEYCODES from 'constants/keycodes';
|
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';
|
2020-05-21 11:38:28 -04:00
|
|
|
import classnames from 'classnames';
|
2021-12-04 22:20:24 -05:00
|
|
|
import Icon from 'component/common/icon';
|
2020-08-10 16:47:39 -04:00
|
|
|
import NotificationBubble from 'component/notificationBubble';
|
2021-12-04 22:20:24 -05:00
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2021-06-09 20:20:19 +01:00
|
|
|
import ChannelThumbnail from 'component/channelThumbnail';
|
2021-12-04 22:20:24 -05:00
|
|
|
import { DOMAIN, ENABLE_UI_NOTIFICATIONS } from 'config';
|
2020-08-20 21:40:52 -04:00
|
|
|
import { IS_MAC } from 'component/app/view';
|
2020-01-03 14:11:47 -05:00
|
|
|
|
2020-08-21 11:18:47 -04:00
|
|
|
const HOME = {
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Home',
|
|
|
|
link: `/`,
|
2020-08-21 11:18:47 -04:00
|
|
|
icon: ICONS.HOME,
|
2020-12-08 11:42:11 -05:00
|
|
|
onClick: () => {
|
|
|
|
if (window.location.pathname === '/') window.location.reload();
|
|
|
|
},
|
2020-08-21 11:18:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const RECENT_FROM_FOLLOWING = {
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Following --[sidebar button]--',
|
|
|
|
link: `/$/${PAGES.CHANNELS_FOLLOWING}`,
|
2020-08-21 11:18:47 -04:00
|
|
|
icon: ICONS.SUBSCRIBE,
|
|
|
|
};
|
|
|
|
|
2018-03-26 14:32:43 -07:00
|
|
|
type Props = {
|
2019-06-11 14:10:58 -04:00
|
|
|
subscriptions: Array<Subscription>,
|
2020-09-02 10:38:40 +08:00
|
|
|
followedTags: Array<Tag>,
|
2019-08-21 16:54:44 -04:00
|
|
|
email: ?string,
|
2019-10-10 20:37:18 -04:00
|
|
|
uploadCount: number,
|
2019-12-18 00:27:08 -05:00
|
|
|
doSignOut: () => void,
|
2020-08-10 16:47:39 -04:00
|
|
|
sidebarOpen: boolean,
|
2021-03-16 09:42:49 +08:00
|
|
|
setSidebarOpen: (boolean) => void,
|
2020-08-10 16:47:39 -04:00
|
|
|
isMediumScreen: boolean,
|
|
|
|
isOnFilePage: boolean,
|
2021-03-16 09:42:49 +08:00
|
|
|
unseenCount: number,
|
2020-05-21 11:38:28 -04:00
|
|
|
purchaseSuccess: boolean,
|
|
|
|
doClearPurchasedUriSuccess: () => void,
|
2020-08-11 16:32:03 -04:00
|
|
|
user: ?User,
|
2020-11-10 11:07:00 -05:00
|
|
|
homepageData: any,
|
|
|
|
};
|
|
|
|
|
|
|
|
type SideNavLink = {
|
|
|
|
title: string,
|
|
|
|
link?: string,
|
2021-05-31 14:26:45 +08:00
|
|
|
route?: string,
|
2020-11-10 11:07:00 -05:00
|
|
|
onClick?: () => any,
|
|
|
|
icon: string,
|
|
|
|
extra?: Node,
|
|
|
|
hideForUnauth?: boolean,
|
2018-03-26 14:32:43 -07:00
|
|
|
};
|
|
|
|
|
2020-01-02 11:30:27 -05:00
|
|
|
function SideNavigation(props: Props) {
|
2019-12-18 00:27:08 -05:00
|
|
|
const {
|
|
|
|
subscriptions,
|
2020-08-20 11:10:29 -04:00
|
|
|
doSignOut,
|
2019-12-18 00:27:08 -05:00
|
|
|
email,
|
2020-05-21 11:38:28 -04:00
|
|
|
purchaseSuccess,
|
|
|
|
doClearPurchasedUriSuccess,
|
2020-08-10 16:47:39 -04:00
|
|
|
sidebarOpen,
|
|
|
|
setSidebarOpen,
|
|
|
|
isMediumScreen,
|
|
|
|
isOnFilePage,
|
2021-03-16 09:42:49 +08:00
|
|
|
unseenCount,
|
2020-08-11 16:32:03 -04:00
|
|
|
user,
|
2021-05-31 14:26:45 +08:00
|
|
|
followedTags,
|
2019-12-18 00:27:08 -05:00
|
|
|
} = props;
|
2020-08-20 11:10:29 -04:00
|
|
|
|
2020-11-17 18:43:12 -05:00
|
|
|
const FULL_LINKS: Array<SideNavLink> = [
|
|
|
|
{
|
|
|
|
title: 'Your Tags',
|
|
|
|
link: `/$/${PAGES.TAGS_FOLLOWING}`,
|
|
|
|
icon: ICONS.TAG,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Discover',
|
|
|
|
link: `/$/${PAGES.DISCOVER}`,
|
|
|
|
icon: ICONS.DISCOVER,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: IS_WEB ? 'Purchased' : 'Library',
|
|
|
|
link: `/$/${PAGES.LIBRARY}`,
|
|
|
|
icon: ICONS.PURCHASED,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
];
|
2020-08-20 11:10:29 -04:00
|
|
|
|
2020-11-10 11:07:00 -05:00
|
|
|
const MOBILE_LINKS: Array<SideNavLink> = [
|
|
|
|
{
|
|
|
|
title: 'Notifications',
|
|
|
|
link: `/$/${PAGES.NOTIFICATIONS}`,
|
|
|
|
icon: ICONS.NOTIFICATION,
|
|
|
|
extra: <NotificationBubble inline />,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
2020-08-20 11:10:29 -04:00
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Upload',
|
|
|
|
link: `/$/${PAGES.UPLOAD}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.PUBLISH,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'New Channel',
|
|
|
|
link: `/$/${PAGES.CHANNEL_NEW}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.CHANNEL,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Uploads',
|
|
|
|
link: `/$/${PAGES.UPLOADS}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.PUBLISH,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Channels',
|
|
|
|
link: `/$/${PAGES.CHANNELS}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.CHANNEL,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Creator Analytics',
|
|
|
|
link: `/$/${PAGES.CREATOR_DASHBOARD}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.ANALYTICS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Wallet',
|
|
|
|
link: `/$/${PAGES.WALLET}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.WALLET,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
2020-11-10 10:35:55 -05:00
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Rewards',
|
2020-11-10 12:21:31 -05:00
|
|
|
link: `/$/${PAGES.REWARDS}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.REWARDS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Invites',
|
|
|
|
link: `/$/${PAGES.INVITE}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.INVITE,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Settings',
|
|
|
|
link: `/$/${PAGES.SETTINGS}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.SETTINGS,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Help',
|
|
|
|
link: `/$/${PAGES.HELP}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.HELP,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Sign Out',
|
2020-08-20 11:10:29 -04:00
|
|
|
onClick: doSignOut,
|
|
|
|
icon: ICONS.SIGN_OUT,
|
|
|
|
hideForUnauth: true,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2020-11-10 11:07:00 -05:00
|
|
|
const UNAUTH_LINKS: Array<SideNavLink> = [
|
2020-08-20 11:10:29 -04:00
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Log In',
|
|
|
|
link: `/$/${PAGES.AUTH_SIGNIN}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.SIGN_IN,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Sign Up',
|
|
|
|
link: `/$/${PAGES.AUTH}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.SIGN_UP,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Settings',
|
|
|
|
link: `/$/${PAGES.SETTINGS}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.SETTINGS,
|
|
|
|
},
|
|
|
|
{
|
2020-11-10 11:07:00 -05:00
|
|
|
title: 'Help',
|
|
|
|
link: `/$/${PAGES.HELP}`,
|
2020-08-20 11:10:29 -04:00
|
|
|
icon: ICONS.HELP,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-07-07 14:21:11 -04:00
|
|
|
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
2019-12-18 00:27:08 -05:00
|
|
|
const isAuthenticated = Boolean(email);
|
2020-11-10 11:07:00 -05:00
|
|
|
// SIDE LINKS: FOLLOWING, HOME, [FULL,] [EXTRA]
|
|
|
|
let SIDE_LINKS: Array<SideNavLink> = [];
|
|
|
|
|
|
|
|
SIDE_LINKS.push(HOME);
|
|
|
|
SIDE_LINKS.push(RECENT_FROM_FOLLOWING);
|
2021-10-18 19:37:58 -04:00
|
|
|
FULL_LINKS.push({
|
|
|
|
title: 'Lists',
|
|
|
|
link: `/$/${PAGES.LISTS}`,
|
|
|
|
icon: ICONS.STACK,
|
|
|
|
hideForUnauth: true,
|
|
|
|
});
|
|
|
|
SIDE_LINKS.push(...FULL_LINKS);
|
2020-11-16 14:26:23 -05:00
|
|
|
|
2020-05-21 11:38:28 -04:00
|
|
|
const [pulseLibrary, setPulseLibrary] = React.useState(false);
|
2020-04-02 13:02:12 -04:00
|
|
|
const isPersonalized = !IS_WEB || isAuthenticated;
|
2020-08-10 16:47:39 -04:00
|
|
|
const isAbsolute = isOnFilePage || isMediumScreen;
|
2020-08-11 16:32:03 -04:00
|
|
|
const microNavigation = !sidebarOpen || isMediumScreen;
|
|
|
|
const subLinks = email
|
2021-03-16 09:42:49 +08:00
|
|
|
? MOBILE_LINKS.filter((link) => {
|
2020-08-11 16:32:03 -04:00
|
|
|
if (!notificationsEnabled && link.icon === ICONS.NOTIFICATION) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
})
|
|
|
|
: UNAUTH_LINKS;
|
2020-11-10 10:35:55 -05:00
|
|
|
|
2020-05-21 11:38:28 -04:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (purchaseSuccess) {
|
|
|
|
setPulseLibrary(true);
|
|
|
|
|
|
|
|
let timeout = setTimeout(() => {
|
|
|
|
setPulseLibrary(false);
|
|
|
|
doClearPurchasedUriSuccess();
|
|
|
|
}, 2500);
|
|
|
|
|
|
|
|
return () => clearTimeout(timeout);
|
|
|
|
}
|
|
|
|
}, [setPulseLibrary, purchaseSuccess, doClearPurchasedUriSuccess]);
|
|
|
|
|
2020-08-10 16:47:39 -04:00
|
|
|
React.useEffect(() => {
|
|
|
|
function handleKeydown(e: SyntheticKeyboardEvent<*>) {
|
2021-08-31 15:05:42 +08:00
|
|
|
if (e.keyCode === KEYCODES.ESCAPE && isAbsolute) {
|
2020-08-10 16:47:39 -04:00
|
|
|
setSidebarOpen(false);
|
2021-08-31 15:05:42 +08:00
|
|
|
} else if (e.keyCode === KEYCODES.BACKSLASH) {
|
2021-07-12 18:54:32 -05:00
|
|
|
const hasActiveInput = document.querySelector('input:focus, textarea:focus');
|
2020-08-10 16:47:39 -04:00
|
|
|
if (!hasActiveInput) {
|
|
|
|
setSidebarOpen(!sidebarOpen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeydown);
|
|
|
|
|
|
|
|
return () => window.removeEventListener('keydown', handleKeydown);
|
|
|
|
}, [sidebarOpen, setSidebarOpen, isAbsolute]);
|
2019-04-19 17:15:41 -04:00
|
|
|
|
2021-12-04 22:20:24 -05:00
|
|
|
const unAuthNudge =
|
|
|
|
DOMAIN === 'lbry.tv' ? null : (
|
|
|
|
<div className="navigation__auth-nudge">
|
|
|
|
<span>
|
|
|
|
<I18nMessage tokens={{ lbc: <Icon icon={ICONS.LBC} /> }}>
|
|
|
|
Sign up to earn %lbc% for you and your favorite creators.
|
|
|
|
</I18nMessage>
|
|
|
|
</span>
|
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
label={__('Sign Up')}
|
|
|
|
navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`}
|
|
|
|
disabled={user === null}
|
|
|
|
/>{' '}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2020-11-10 11:10:09 -05:00
|
|
|
const helpLinks = (
|
|
|
|
<ul className="navigation__tertiary navigation-links--small">
|
|
|
|
<li className="navigation-link">
|
2021-10-11 09:43:29 +08:00
|
|
|
<Button label={__('About --[link title in Sidebar or Footer]--')} href="https://lbry.com/about" />
|
|
|
|
</li>
|
|
|
|
<li className="navigation-link">
|
2021-10-21 16:56:15 -04:00
|
|
|
<Button label={__('FAQ')} href="https://lbry.com/faq" />
|
2020-11-10 11:10:09 -05:00
|
|
|
</li>
|
|
|
|
<li className="navigation-link">
|
2021-10-11 09:43:29 +08:00
|
|
|
<Button label={__('Support --[used in footer; general help/support]--')} href="https://lbry.com/support" />
|
|
|
|
</li>
|
|
|
|
<li className="navigation-link">
|
|
|
|
<Button label={__('Terms')} href="https://lbry.com/termsofservice" />
|
2020-11-10 11:10:09 -05:00
|
|
|
</li>
|
|
|
|
<li className="navigation-link">
|
2021-10-11 09:43:29 +08:00
|
|
|
<Button label={__('Privacy Policy')} href="https://lbry.com/privacy" />
|
2020-11-10 11:10:09 -05:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
|
2020-01-24 13:31:49 -05:00
|
|
|
return (
|
2020-08-11 16:32:03 -04:00
|
|
|
<div
|
|
|
|
className={classnames('navigation__wrapper', {
|
|
|
|
'navigation__wrapper--micro': microNavigation && !isOnFilePage,
|
|
|
|
'navigation__wrapper--absolute': isAbsolute,
|
|
|
|
})}
|
|
|
|
>
|
2020-08-10 16:47:39 -04:00
|
|
|
{!isOnFilePage && (
|
2020-08-21 00:13:47 -04:00
|
|
|
<nav
|
2021-07-14 22:08:30 -05:00
|
|
|
aria-label={'Sidebar'}
|
2020-08-21 00:13:47 -04:00
|
|
|
className={classnames('navigation', {
|
|
|
|
'navigation--micro': microNavigation,
|
|
|
|
// @if TARGET='app'
|
|
|
|
'navigation--mac': IS_MAC,
|
|
|
|
// @endif
|
|
|
|
})}
|
|
|
|
>
|
2020-08-26 17:16:45 -04:00
|
|
|
<div>
|
|
|
|
<ul className={classnames('navigation-links', { 'navigation-links--micro': !sidebarOpen })}>
|
2021-03-16 09:42:49 +08:00
|
|
|
{SIDE_LINKS.map((linkProps) => {
|
2020-11-10 11:07:00 -05:00
|
|
|
// $FlowFixMe
|
2020-08-25 18:00:47 -04:00
|
|
|
const { hideForUnauth, ...passedProps } = linkProps;
|
2020-08-26 17:16:45 -04:00
|
|
|
return !email && linkProps.hideForUnauth && IS_WEB ? null : (
|
2021-05-31 14:26:45 +08:00
|
|
|
<li key={linkProps.route || linkProps.link}>
|
2020-08-11 16:32:03 -04:00
|
|
|
<Button
|
2020-08-25 18:00:47 -04:00
|
|
|
{...passedProps}
|
2020-11-10 11:07:00 -05:00
|
|
|
label={__(linkProps.title)}
|
2020-11-10 04:32:50 +08:00
|
|
|
title={__(linkProps.title)}
|
2020-11-10 11:07:00 -05:00
|
|
|
// $FlowFixMe
|
|
|
|
navigate={linkProps.route || linkProps.link}
|
2020-08-11 16:32:03 -04:00
|
|
|
icon={pulseLibrary && linkProps.icon === ICONS.LIBRARY ? ICONS.PURCHASED : linkProps.icon}
|
|
|
|
className={classnames('navigation-link', {
|
|
|
|
'navigation-link--pulse': linkProps.icon === ICONS.LIBRARY && pulseLibrary,
|
2021-03-16 09:42:49 +08:00
|
|
|
'navigation-link--highlighted': linkProps.icon === ICONS.NOTIFICATION && unseenCount > 0,
|
2020-08-11 16:32:03 -04:00
|
|
|
})}
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
/>
|
2020-11-10 11:07:00 -05:00
|
|
|
{linkProps.extra && linkProps.extra}
|
2020-08-11 16:32:03 -04:00
|
|
|
</li>
|
2020-08-25 18:00:47 -04:00
|
|
|
);
|
|
|
|
})}
|
2020-08-10 16:47:39 -04:00
|
|
|
</ul>
|
2020-08-25 18:00:47 -04:00
|
|
|
|
2020-08-26 17:16:45 -04:00
|
|
|
{sidebarOpen && isPersonalized && subscriptions && subscriptions.length > 0 && (
|
2020-11-10 11:07:00 -05:00
|
|
|
<ul className="navigation__secondary navigation-links">
|
2021-06-09 20:20:19 +01:00
|
|
|
{subscriptions.map((subscription) => (
|
|
|
|
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
|
2020-08-10 16:47:39 -04:00
|
|
|
))}
|
|
|
|
</ul>
|
2019-12-19 15:43:49 -05:00
|
|
|
)}
|
2021-04-13 16:47:51 -04:00
|
|
|
{sidebarOpen && isPersonalized && followedTags && followedTags.length > 0 && (
|
2020-09-08 15:46:06 -04:00
|
|
|
<ul className="navigation__secondary navigation-links navigation-links--small">
|
|
|
|
{followedTags.map(({ name }, key) => (
|
|
|
|
<li key={name} className="navigation-link__wrapper">
|
|
|
|
<Button navigate={`/$/discover?t=${name}`} label={`#${name}`} className="navigation-link" />
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
)}
|
2021-12-04 22:20:24 -05:00
|
|
|
|
|
|
|
{!isAuthenticated && sidebarOpen && unAuthNudge}
|
2020-08-26 17:16:45 -04:00
|
|
|
</div>
|
2020-11-10 11:10:09 -05:00
|
|
|
|
2021-10-18 19:37:58 -04:00
|
|
|
{sidebarOpen && helpLinks}
|
2020-08-26 17:16:45 -04:00
|
|
|
</nav>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{(isOnFilePage || isMediumScreen) && sidebarOpen && (
|
|
|
|
<>
|
|
|
|
<nav
|
|
|
|
className={classnames('navigation--absolute', {
|
|
|
|
// @if TARGET='app'
|
|
|
|
'navigation--mac': IS_MAC,
|
|
|
|
// @endif
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<ul className="navigation-links--absolute">
|
2021-03-16 09:42:49 +08:00
|
|
|
{SIDE_LINKS.map((linkProps) => {
|
2020-11-10 11:07:00 -05:00
|
|
|
// $FlowFixMe
|
|
|
|
const { hideForUnauth, link, route, ...passedProps } = linkProps;
|
|
|
|
return !email && linkProps.hideForUnauth && IS_WEB ? null : (
|
2020-12-17 13:43:47 -05:00
|
|
|
<li key={route || link}>
|
2020-08-26 17:16:45 -04:00
|
|
|
<Button
|
|
|
|
{...passedProps}
|
2020-11-10 11:07:00 -05:00
|
|
|
navigate={route || link}
|
|
|
|
label={__(linkProps.title)}
|
2020-11-10 04:32:50 +08:00
|
|
|
title={__(linkProps.title)}
|
2020-08-26 17:16:45 -04:00
|
|
|
icon={pulseLibrary && linkProps.icon === ICONS.LIBRARY ? ICONS.PURCHASED : linkProps.icon}
|
|
|
|
className={classnames('navigation-link', {
|
|
|
|
'navigation-link--pulse': linkProps.icon === ICONS.LIBRARY && pulseLibrary,
|
2021-03-16 09:42:49 +08:00
|
|
|
'navigation-link--highlighted': linkProps.icon === ICONS.NOTIFICATION && unseenCount > 0,
|
2020-08-26 17:16:45 -04:00
|
|
|
})}
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
/>
|
2020-11-10 11:07:00 -05:00
|
|
|
{linkProps.extra && linkProps.extra}
|
2020-08-26 17:16:45 -04:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
})}
|
2020-09-02 10:38:40 +08:00
|
|
|
</ul>
|
2020-11-10 11:07:00 -05:00
|
|
|
<ul className="navigation-links--absolute mobile-only">
|
2021-03-16 09:42:49 +08:00
|
|
|
{subLinks.map((linkProps) => {
|
2020-08-26 17:16:45 -04:00
|
|
|
const { hideForUnauth, ...passedProps } = linkProps;
|
|
|
|
|
|
|
|
return !email && hideForUnauth && IS_WEB ? null : (
|
2020-12-17 13:43:47 -05:00
|
|
|
<li key={linkProps.title} className="mobile-only">
|
2020-08-26 17:16:45 -04:00
|
|
|
<Button
|
|
|
|
{...passedProps}
|
2020-11-10 11:07:00 -05:00
|
|
|
navigate={linkProps.link}
|
|
|
|
label={__(linkProps.title)}
|
2020-11-10 04:32:50 +08:00
|
|
|
title={__(linkProps.title)}
|
2020-08-26 17:16:45 -04:00
|
|
|
className="navigation-link"
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
/>
|
|
|
|
{linkProps.extra}
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ul>
|
2020-11-10 11:07:00 -05:00
|
|
|
{sidebarOpen && isPersonalized && subscriptions && subscriptions.length > 0 && (
|
|
|
|
<ul className="navigation__secondary navigation-links">
|
2021-06-09 20:20:19 +01:00
|
|
|
{subscriptions.map((subscription) => (
|
|
|
|
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
|
2020-08-26 17:16:45 -04:00
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
)}
|
2021-04-13 16:47:51 -04:00
|
|
|
{sidebarOpen && isPersonalized && followedTags && followedTags.length > 0 && (
|
2020-09-08 15:46:06 -04:00
|
|
|
<ul className="navigation__secondary navigation-links navigation-links--small">
|
|
|
|
{followedTags.map(({ name }, key) => (
|
|
|
|
<li key={name} className="navigation-link__wrapper">
|
|
|
|
<Button navigate={`/$/discover?t=${name}`} label={`#${name}`} className="navigation-link" />
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
)}
|
2021-12-04 22:20:24 -05:00
|
|
|
{!isAuthenticated && unAuthNudge}
|
2020-08-26 17:16:45 -04:00
|
|
|
</div>
|
2020-08-10 16:47:39 -04:00
|
|
|
</nav>
|
2020-08-20 21:40:52 -04:00
|
|
|
<div
|
|
|
|
className={classnames('navigation__overlay', {
|
2020-08-21 00:13:47 -04:00
|
|
|
// @if TARGET='app'
|
2020-08-20 21:40:52 -04:00
|
|
|
'navigation__overlay--mac': IS_MAC,
|
2020-08-21 00:13:47 -04:00
|
|
|
// @endif
|
2020-08-20 21:40:52 -04:00
|
|
|
})}
|
|
|
|
onClick={() => setSidebarOpen(false)}
|
|
|
|
/>
|
2020-08-10 16:47:39 -04:00
|
|
|
</>
|
|
|
|
)}
|
2020-08-11 16:32:03 -04:00
|
|
|
</div>
|
2019-06-11 14:10:58 -04:00
|
|
|
);
|
2019-01-26 19:23:47 -05:00
|
|
|
}
|
2018-03-26 14:32:43 -07:00
|
|
|
|
2021-06-09 20:20:19 +01:00
|
|
|
function SubscriptionListItem({ subscription }: { subscription: Subscription }) {
|
|
|
|
const { uri, channelName } = subscription;
|
|
|
|
return (
|
|
|
|
<li className="navigation-link__wrapper">
|
|
|
|
<Button
|
|
|
|
navigate={uri}
|
|
|
|
className="navigation-link navigation-link--with-thumbnail"
|
|
|
|
activeClass="navigation-link--active"
|
|
|
|
>
|
ChannelThumbnail improvements
- [x] (6332) The IntersectionObserver method of lazy-loading loads cached images visibly late on slower devices. Previously, it was also showing the "broken image" icon briefly, which we mended by placing a dummy transparent image as the initial src.
- Reverted that ugly transparent image fix.
- Use the browser's built-in `loading="lazy"` instead. Sorry, Safari.
- [x] Size-optimization did not take "device pixel ratio" into account.
- When resizing an image through the CDN, we can't just take the dimensions of the tag in pixels directly -- we need to take zooming into account, otherwise the image ends up blurry.
- Previously, we quickly disabled optimization for the channel avatar in the Channel Page because of this. Now that we know the root-cause, the change was reverted and we now go through the CDN with appropriate sizes. This also improves our Web Vital scores.
- [x] Size-optimization wasn't really implemented for all ChannelThumbnail instances.
- The CDN-optimized size was hardcoded to the largest instance, so small images like sidebar thumbnails are still loading images that are unnecessarily larger.
- There's a little-bit of hardcoding of values from CSS here, but I think it's a ok compromise (not something we change often). It also doesn't need to be exact -- the "device pixel ratio" calculate will ensure it's slightly larger than what we need.
- [x] Set `width` and `height` of `<img>` to improve CLS.
- Addresses Ligthhouse complaints, although technically the shifting was addressed at the `ClaimPreviewTile` level (sub-container dimensions are well defined).
- Notes: the values don't need to be the final CSS-adjusted sizes. It just needs to be in the right aspect ratio to help the browser pre-allocate space to avoid shifts.
- [x] Add option to disable lazy-load Channel Thumbnails
- The guidelines mentioned that items that are already in the viewport should not enable `loading="lazy"`.
- We have a few areas where it doesn't make sense to lazy-load (e.g. thumbnail in Header, channel selector dropdown, publish preview, etc.).
2021-07-05 13:20:40 +08:00
|
|
|
<ChannelThumbnail xsmall uri={uri} hideStakedIndicator />
|
2021-06-09 20:20:19 +01:00
|
|
|
<span dir="auto" className="button__label">
|
|
|
|
{channelName}
|
|
|
|
</span>
|
|
|
|
</Button>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-10 16:47:39 -04:00
|
|
|
export default SideNavigation;
|