({
group,
pathname,
}: {
group: NavGroup
pathname: string
})
| 64 | } |
| 65 | |
| 66 | function VisibleSectionHighlight({ |
| 67 | group, |
| 68 | pathname, |
| 69 | }: { |
| 70 | group: NavGroup |
| 71 | pathname: string |
| 72 | }) { |
| 73 | let [sections, visibleSections] = useInitialValue( |
| 74 | [ |
| 75 | useSectionStore((s) => s.sections), |
| 76 | useSectionStore((s) => s.visibleSections), |
| 77 | ], |
| 78 | useIsInsideMobileNavigation(), |
| 79 | ) |
| 80 | |
| 81 | let isPresent = useIsPresent() |
| 82 | let firstVisibleSectionIndex = Math.max( |
| 83 | 0, |
| 84 | [{ id: '_top' }, ...sections].findIndex( |
| 85 | (section) => section.id === visibleSections[0], |
| 86 | ), |
| 87 | ) |
| 88 | let itemHeight = remToPx(2) |
| 89 | let height = isPresent |
| 90 | ? Math.max(1, visibleSections.length) * itemHeight |
| 91 | : itemHeight |
| 92 | let top = |
| 93 | group.links.findIndex((link) => matchPath(pathname, link.href)) * |
| 94 | itemHeight + |
| 95 | firstVisibleSectionIndex * itemHeight |
| 96 | |
| 97 | return ( |
| 98 | <motion.div |
| 99 | layout |
| 100 | initial={{ opacity: 0 }} |
| 101 | animate={{ opacity: 1 }} |
| 102 | transition={{ duration: 0.15 }} |
| 103 | exit={{ opacity: 0 }} |
| 104 | className="absolute inset-x-0 top-0 bg-zinc-800/2.5 will-change-transform dark:bg-white/2.5" |
| 105 | style={{ borderRadius: 8, height, top }} |
| 106 | /> |
| 107 | ) |
| 108 | } |
| 109 | |
| 110 | function ActivePageMarker({ |
| 111 | group, |
nothing calls this directly
no test coverage detected