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

Function MainLayoutComponent

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

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

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