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

Function MainLayoutComponent

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

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