Tweak sidebar to update navigation highlight on scroll

This commit is contained in:
jxom
2017-10-07 18:33:53 +11:00
parent 0047452833
commit 94270569a5
3 changed files with 157 additions and 77 deletions

View File

@@ -65,15 +65,22 @@ const createLinkDocs = ({item, location, section}) => {
);
};
const createLinkTutorial = ({item, location, onLinkClick, section}) => {
const isActive = isItemActive(location, item);
const createLinkTutorial = ({
item,
location,
onLinkClick,
section,
isActive,
}) => {
const active =
typeof isActive === 'boolean' ? isActive : isItemActive(location, item);
return (
<Link
css={[linkCss, isActive && activeLinkCss]}
css={[linkCss, active && activeLinkCss]}
onClick={onLinkClick}
to={item.href}>
{isActive && <span css={activeLinkBefore} />}
{active && <span css={activeLinkBefore} />}
{item.title}
</Link>
);