diff --git a/app/src/organisms/Navigation/index.tsx b/app/src/organisms/Navigation/index.tsx index a9a55f53e63..c1389ce9b95 100644 --- a/app/src/organisms/Navigation/index.tsx +++ b/app/src/organisms/Navigation/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' -import { NavLink } from 'react-router-dom' +import { useLocation, NavLink } from 'react-router-dom' import styled from 'styled-components' import { @@ -39,15 +39,19 @@ const NAV_LINKS: Array = [ '/robot-settings', ] -// TODO(sb:7/10/24): update this wrapper to fade on both sides only when not scrolled completely to that side -// This will be accomplished in PLAT-399 const CarouselWrapper = styled.div` display: ${DISPLAY_FLEX}; flex-direction: ${DIRECTION_ROW}; align-items: ${ALIGN_FLEX_START}; - width: 42.25rem; + width: 56.75rem; overflow-x: ${OVERFLOW_SCROLL}; - -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); + -webkit-mask-image: linear-gradient( + to right, + transparent 0%, + black 1%, + black 99%, + transparent 100% + ); &::-webkit-scrollbar { display: none; } @@ -65,6 +69,7 @@ interface NavigationProps { export function Navigation(props: NavigationProps): JSX.Element { const { setNavMenuIsOpened, longPressModalIsOpened } = props const { t } = useTranslation('top_navigation') + const location = useLocation() const localRobot = useSelector(getLocalRobot) const [showNavMenu, setShowNavMenu] = React.useState(false) const robotName = localRobot?.name != null ? localRobot.name : 'no name' @@ -95,6 +100,15 @@ export function Navigation(props: NavigationProps): JSX.Element { if (scrollRef.current != null) { observer.observe(scrollRef.current) } + + const navBarScrollRef = React.useRef(null) + React.useEffect(() => { + navBarScrollRef?.current?.scrollIntoView({ + behavior: 'auto', + inline: 'center', + }) + }, []) + function getPathDisplayName(path: typeof NAV_LINKS[number]): string { switch (path) { case '/instruments': @@ -134,35 +148,41 @@ export function Navigation(props: NavigationProps): JSX.Element { aria-label="Navigation_container" > - - - {iconName != null ? ( - - ) : null} - - {NAV_LINKS.map(path => ( + + + {iconName != null ? ( + + ) : null} + {NAV_LINKS.map(path => ( + + + ))}