MCPcopy Create free account
hub / github.com/dailydotdev/apps / useActiveNav

Function useActiveNav

packages/shared/src/hooks/useActiveNav.tsx:20–79  ·  view source on GitHub ↗
(activeFeed: AllFeedPages)

Source from the content-addressed store, hash-verified

18}
19
20export default function useActiveNav(activeFeed: AllFeedPages): UseActiveNav {
21 const router = useRouter();
22 const isMobile = useViewSize(ViewSize.MobileL);
23 const isHomeActive = useMemo(() => {
24 const homePages = [
25 SharedFeedPage.MyFeed,
26 SharedFeedPage.Popular,
27 SharedFeedPage.Upvoted,
28 OtherFeedPage.History,
29 SharedFeedPage.Custom,
30 SharedFeedPage.CustomForm,
31 OtherFeedPage.Tags,
32 OtherFeedPage.Sources,
33 OtherFeedPage.Leaderboard,
34 OtherFeedPage.Following,
35 ];
36
37 if (!isMobile) {
38 homePages.push(OtherFeedPage.Notifications);
39 }
40
41 if (homePages.includes(activeFeed)) {
42 return true;
43 }
44
45 // if post page the [id] was expected
46 return withoutLayoutVariantPrefix(router?.route).startsWith('/posts/[id]');
47 }, [activeFeed, isMobile, router?.route]);
48
49 const explorePages: AllFeedPages[] = [
50 SharedFeedPage.Search,
51 OtherFeedPage.Explore,
52 OtherFeedPage.ExploreLatest,
53 OtherFeedPage.ExploreUpvoted,
54 OtherFeedPage.ExploreDiscussed,
55 ];
56 const isProfileActive = router.pathname?.includes('/[userId]');
57 const isJobsActive = router.pathname?.startsWith('/jobs');
58 const isHighlightsActive = router.pathname?.startsWith('/highlights');
59 const isExploreActive = explorePages.includes(activeFeed);
60 const bookmarksPages: AllFeedPages[] = [
61 OtherFeedPage.Bookmarks,
62 OtherFeedPage.BookmarkLater,
63 OtherFeedPage.BookmarkFolder,
64 ];
65 const isBookmarksActive = bookmarksPages.includes(activeFeed);
66 const isNotificationsActive = activeFeed === OtherFeedPage.Notifications;
67 const isSquadsActive = activeFeed.includes(OtherFeedPage.Squad);
68
69 return {
70 home: isHomeActive,
71 profile: isProfileActive,
72 bookmarks: isBookmarksActive,
73 notifications: isNotificationsActive,
74 explore: isExploreActive,
75 squads: isSquadsActive,
76 jobs: isJobsActive,
77 highlights: isHighlightsActive,

Callers 4

MainLayoutHeaderFunction · 0.85
useShellBlockPlanFunction · 0.85
SidebarTabletFunction · 0.85
FeedNavFunction · 0.85

Calls 4

useViewSizeFunction · 0.90
pushMethod · 0.80
useRouterFunction · 0.50

Tested by

no test coverage detected