// @flow import React from 'react'; import compose from 'recompose/compose'; import { withRouter, Route, type History } from 'react-router-dom'; import Tooltip from 'src/components/tooltip'; import { UserAvatar } from 'src/components/avatar'; import { isViewingMarketingPage } from 'src/helpers/is-viewing-marketing-page'; import { withCurrentUser } from 'src/components/withCurrentUser'; import { Overlay, NavigationWrapper, NavigationGrid, AvatarGrid, AvatarLink, Label, IconWrapper, Divider, DesktopMenuIconsCover, } from './style'; import Icon from 'src/components/icon'; import NavHead from './navHead'; import DirectMessagesTab from './directMessagesTab'; import { Skip, getAccessibilityActiveState } from './accessibility'; import CommunityList from './communityList'; import { NavigationContext } from 'src/helpers/navigation-context'; import { MIN_WIDTH_TO_EXPAND_NAVIGATION } from 'src/components/layout'; type Props = { history: History, currentUser?: Object, isLoadingCurrentUser: boolean, }; const Navigation = (props: Props) => { const { currentUser, history, isLoadingCurrentUser } = props; const isMarketingPage = isViewingMarketingPage(history, currentUser); if (isMarketingPage) return null; const isWideViewport = window && window.innerWidth > MIN_WIDTH_TO_EXPAND_NAVIGATION; if (!isLoadingCurrentUser && !currentUser) { return ( {({ navigationIsOpen, setNavigationIsOpen }) => ( setNavigationIsOpen(false)} /> {({ match }) => ( setNavigationIsOpen(false)} {...getAccessibilityActiveState(!!match)} > )} {({ match }) => ( setNavigationIsOpen(false)} {...getAccessibilityActiveState(!!match)} > )} )} ); } if (currentUser) { return ( {({ navigationIsOpen, setNavigationIsOpen }) => ( setNavigationIsOpen(false)} /> {({ match }) => } {({ match }) => ( setNavigationIsOpen(false)} {...getAccessibilityActiveState( match && match.url === '/explore' && match.isExact )} > )} {({ match }) => ( setNavigationIsOpen(false)} {...getAccessibilityActiveState( history.location.pathname === `/users/${currentUser.username}` )} > )} )} ); } return ; }; export default compose( withCurrentUser, withRouter )(Navigation);