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

Function MainLayoutComponent

packages/shared/src/components/MainLayout.tsx:104–491  ·  view source on GitHub ↗
({
  children,
  activePage,
  isNavItemsButton,
  customBanner,
  additionalButtons,
  showSidebar = true,
  className,
  onLogoClick,
  onNavTabClick,
  canGoBack,
  hideFeedbackWidget = false,
  topBanner,
}: MainLayoutProps)

Source from the content-addressed store, hash-verified

102export const feeds = Object.values(SharedFeedPage);
103
104function MainLayoutComponent({
105 children,
106 activePage,
107 isNavItemsButton,
108 customBanner,
109 additionalButtons,
110 showSidebar = true,
111 className,
112 onLogoClick,
113 onNavTabClick,
114 canGoBack,
115 hideFeedbackWidget = false,
116 topBanner,
117}: MainLayoutProps): ReactElement | null {
118 const router = useRouter();
119 const { logEvent } = useLogContext();
120 const { user, isAuthReady, isAuthReadyOrCached, isLoggedIn, showLogin } =
121 useAuthContext();
122 const { growthbook } = useGrowthBookContext();
123 const { sidebarRendered } = useSidebarRendered();
124 const { isAvailable: isBannerAvailable } = useBanner();
125 const { sidebarExpanded, autoDismissNotifications, loadedSettings } =
126 useContext(SettingsContext);
127 const { value: isSidebarCompact } = useSidebarCompact();
128 const collapsedPadding = isSidebarCompact
129 ? 'tablet:pl-16 laptop:pl-16'
130 : 'tablet:pl-16 laptop:pl-20';
131 const expandedPadding = isSidebarCompact
132 ? 'laptop:!pl-[19rem]'
133 : 'laptop:!pl-[20rem]';
134 const [hasLoggedImpression, setHasLoggedImpression] = useState(false);
135 const { feedName } = useActiveFeedNameContext();
136 const page = router?.route?.substring(1).trim() as SharedFeedPage;
137 const currentFeedName = feedName ?? page ?? SharedFeedPage.Popular;
138 const { isCustomFeed } = useFeedName({
139 feedName: currentFeedName,
140 });
141 const { plusEntryAnnouncementBar } = usePlusEntry();
142 const { isNotificationsReady, unreadCount } = useNotificationContext();
143 const isLaptopLayout = useLaptopLayout();
144 const { rest: shellBlockRest } = useShellBlockPlan();
145 useLayoutVariantCookie();
146 // The store is device-wide, so anonymous browsing must not seed the next
147 // signed-in session's Recent list.
148 useRecordRecentPages(isLaptopLayout && isLoggedIn);
149 useNotificationParams();
150 useFeedbackShortcut();
151
152 // Settings pages render their navigation only inside the sidebar's context
153 // panel, so the sidebar force-expands there regardless of the stored
154 // preference. Mirror that here so the floating content keeps its
155 // expanded-width padding and never slides under the panel. Matches the
156 // `activePage` resolution the Sidebar receives below.
157 const forceSidebarExpanded =
158 isLaptopLayout &&
159 isSidebarSettingsPath(activePage ?? router.asPath ?? router.pathname ?? '');
160
161 // The main content's left padding settles from the rail width to the

Callers

nothing calls this directly

Calls 15

useLogContextFunction · 0.90
useAuthContextFunction · 0.90
useGrowthBookContextFunction · 0.90
useBannerFunction · 0.90
useSidebarCompactFunction · 0.90
useActiveFeedNameContextFunction · 0.90
useFeedNameFunction · 0.90
useNotificationContextFunction · 0.90
useLaptopLayoutFunction · 0.90
useShellBlockPlanFunction · 0.90
useLayoutVariantCookieFunction · 0.90
useRecordRecentPagesFunction · 0.90

Tested by

no test coverage detected