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

Function MainLayoutComponent

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

Source from the content-addressed store, hash-verified

96export const feeds = Object.values(SharedFeedPage);
97
98function MainLayoutComponent({
99 children,
100 activePage,
101 isNavItemsButton,
102 customBanner,
103 additionalButtons,
104 screenCentered = true,
105 showSidebar = true,
106 className,
107 onLogoClick,
108 onNavTabClick,
109 canGoBack,
110 hideFeedbackWidget = false,
111 topBanner,
112}: MainLayoutProps): ReactElement | null {
113 const router = useRouter();
114 const { logEvent } = useLogContext();
115 const { user, isAuthReady, isAuthReadyOrCached, isLoggedIn, showLogin } =
116 useAuthContext();
117 const { growthbook } = useGrowthBookContext();
118 const { sidebarRendered } = useSidebarRendered();
119 const { isAvailable: isBannerAvailable } = useBanner();
120 const { sidebarExpanded, autoDismissNotifications, loadedSettings } =
121 useContext(SettingsContext);
122 const { value: isSidebarCompact } = useSidebarCompact();
123 const v2CollapsedPadding = isSidebarCompact
124 ? 'tablet:pl-16 laptop:pl-16'
125 : 'tablet:pl-16 laptop:pl-20';
126 const v2ExpandedPadding = isSidebarCompact
127 ? 'laptop:!pl-[19rem]'
128 : 'laptop:!pl-[20rem]';
129 const [hasLoggedImpression, setHasLoggedImpression] = useState(false);
130 const { feedName } = useActiveFeedNameContext();
131 const page = router?.route?.substring(1).trim() as SharedFeedPage;
132 const currentFeedName = feedName ?? page ?? SharedFeedPage.Popular;
133 const { isCustomFeed, isExploreTag } = useFeedName({
134 feedName: currentFeedName,
135 });
136 const { plusEntryAnnouncementBar } = usePlusEntry();
137 const isLaptop = useViewSize(ViewSize.Laptop);
138 const isLaptopXL = useViewSize(ViewSize.LaptopXL);
139 const { screenCenteredOnMobileLayout } = useFeedLayout();
140 const { isNotificationsReady, unreadCount } = useNotificationContext();
141 const { isV2, isLoading: isLayoutVariantLoading } = useLayoutVariant();
142 const hasServerShell = useContext(LayoutVariantContext) === 'v2';
143 useLayoutVariantCookie();
144 useRecordRecentPages(isV2);
145 useNotificationParams();
146 useFeedbackShortcut();
147
148 // Settings pages render their navigation only inside the v2 context panel,
149 // so the sidebar force-expands there regardless of the stored preference.
150 // Mirror that here so the floating content keeps its expanded-width padding
151 // and never slides under the panel. Matches the `activePage` resolution the
152 // Sidebar receives below.
153 const forceSidebarExpanded =
154 isV2 &&
155 isSidebarSettingsPath(activePage ?? router.asPath ?? router.pathname ?? '');

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
useViewSizeFunction · 0.90
useFeedLayoutFunction · 0.90
useNotificationContextFunction · 0.90
useLayoutVariantFunction · 0.90
useLayoutVariantCookieFunction · 0.90

Tested by

no test coverage detected