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

Function MainLayoutComponent

packages/shared/src/components/MainLayout.tsx:105–494  ·  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

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