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

Function MainLayoutComponent

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

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

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