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

Function MainLayoutComponent

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

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

Callers

nothing calls this directly

Calls 15

useLogContextFunction · 0.90
useAuthContextFunction · 0.90
useGrowthBookContextFunction · 0.90
useBannerFunction · 0.90
useActiveFeedNameContextFunction · 0.90
useFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useFeedLayoutFunction · 0.90
useNotificationContextFunction · 0.90
useLayoutVariantFunction · 0.90
useRecordRecentPagesFunction · 0.90
useNotificationParamsFunction · 0.90

Tested by

no test coverage detected