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

Function MainLayoutComponent

packages/shared/src/components/MainLayout.tsx:98–491  ·  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, isLoggedIn, showLogin } = useAuthContext();
116 const { growthbook } = useGrowthBookContext();
117 const { sidebarRendered } = useSidebarRendered();
118 const { isAvailable: isBannerAvailable } = useBanner();
119 const { sidebarExpanded, autoDismissNotifications, loadedSettings } =
120 useContext(SettingsContext);
121 const { value: isSidebarCompact } = useSidebarCompact();
122 const v2CollapsedPadding = isSidebarCompact
123 ? 'tablet:pl-16 laptop:pl-16'
124 : 'tablet:pl-16 laptop:pl-20';
125 const v2ExpandedPadding = isSidebarCompact
126 ? 'laptop:!pl-[19rem]'
127 : 'laptop:!pl-[20rem]';
128 const [hasLoggedImpression, setHasLoggedImpression] = useState(false);
129 const { feedName } = useActiveFeedNameContext();
130 const page = router?.route?.substring(1).trim() as SharedFeedPage;
131 const currentFeedName = feedName ?? page ?? SharedFeedPage.Popular;
132 const { isCustomFeed, isExploreTag } = useFeedName({
133 feedName: currentFeedName,
134 });
135 const { plusEntryAnnouncementBar } = usePlusEntry();
136 const isLaptop = useViewSize(ViewSize.Laptop);
137 const isLaptopXL = useViewSize(ViewSize.LaptopXL);
138 const { screenCenteredOnMobileLayout } = useFeedLayout();
139 const { isNotificationsReady, unreadCount } = useNotificationContext();
140 const { isV2, isLoading: isLayoutVariantLoading } = useLayoutVariant();
141 const hasServerShell = useContext(LayoutVariantContext) === 'v2';
142 useLayoutVariantCookie();
143 useRecordRecentPages(isV2);
144 useNotificationParams();
145 useFeedbackShortcut();
146
147 // Settings pages render their navigation only inside the v2 context panel,
148 // so the sidebar force-expands there regardless of the stored preference.
149 // Mirror that here so the floating content keeps its expanded-width padding
150 // and never slides under the panel. Matches the `activePage` resolution the
151 // Sidebar receives below.
152 const forceSidebarExpanded =
153 isV2 &&
154 isSidebarSettingsPath(activePage ?? router.asPath ?? router.pathname ?? '');
155

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