Taichi Masuyama 3 лет назад
Родитель
Сommit
01a78c77aa

+ 12 - 5
packages/app/src/components/Layout/BasicLayout.tsx

@@ -11,6 +11,7 @@ import { GrowiNavbar } from '../Navbar/GrowiNavbar';
 import Sidebar from '../Sidebar';
 
 import { RawLayout } from './RawLayout';
+import { useEditorMode } from '~/stores/ui';
 
 const AlertSiteUrlUndefined = dynamic(() => import('../AlertSiteUrlUndefined').then(mod => mod.AlertSiteUrlUndefined), { ssr: false });
 const HotkeysManager = dynamic(() => import('../Hotkeys/HotkeysManager'), { ssr: false });
@@ -30,21 +31,27 @@ const Fab = dynamic(() => import('../Fab').then(mod => mod.Fab), { ssr: false })
 
 
 type Props = {
-  className?: string,
   children?: ReactNode
 }
 
-export const BasicLayout = ({ children, className }: Props): JSX.Element => {
-  const { data: currentPage } = useSWRxCurrentPage();
-  const { data: dataIsContainerFluid } = useIsContainerFluid();
+export const BasicLayout = ({ children }: Props): JSX.Element => {
+  const { data: currentPage } = useSWRxCurrentPage(); // Only /page, /share
+  const { data: dataIsContainerFluid } = useIsContainerFluid(); // Only /page, /share
+  const { getClassNamesByEditorMode } = useEditorMode(); // Only /page
 
+  // Only /page, /share
   const isContainerFluidEachPage = currentPage == null || !('expandContentWidth' in currentPage)
     ? null
     : currentPage.expandContentWidth;
   const isContainerFluidDefault = dataIsContainerFluid;
   const isContainerFluid = isContainerFluidEachPage ?? isContainerFluidDefault;
 
-  const myClassName = `${className ?? ''} ${isContainerFluid ? 'growi-layout-fluid' : ''}`;
+  // Only /page
+  const classNames: string[] = [];
+  const isSidebar = currentPage?.path === '/Sidebar';
+  classNames.push(...getClassNamesByEditorMode(isSidebar));
+
+  const myClassName = `${classNames.join(' ') ?? ''} ${isContainerFluid ? 'growi-layout-fluid' : ''}`;
 
   return (
     <RawLayout className={myClassName}>

+ 2 - 8
packages/app/src/components/Layout/SearchResultLayout.tsx

@@ -5,22 +5,16 @@ import { BasicLayout } from '~/components/Layout/BasicLayout';
 import commonStyles from './SearchResultLayout.module.scss';
 
 type Props = {
-  className?: string,
   children?: ReactNode,
 }
 
 const SearchResultLayout = ({
-  children, className,
+  children,
 }: Props): JSX.Element => {
 
-  const classNames: string[] = [];
-  if (className != null) {
-    classNames.push(className);
-  }
-
   return (
     <div className={`on-search ${commonStyles['on-search']}`}>
-      <BasicLayout className={classNames.join(' ')}>
+      <BasicLayout>
         <div id="grw-fav-sticky-trigger" className="sticky-top"></div>
         <div id="main" className="main search-page mt-0">
           { children }

+ 0 - 7
packages/app/src/pages/[[...path]].page.tsx

@@ -267,8 +267,6 @@ const Page: NextPage<Props> = (props: Props) => {
   const { data: grantData } = useSWRxIsGrantNormalized(pageId);
   const { mutate: mutateSelectedGrant } = useSelectedGrant();
 
-  const { getClassNamesByEditorMode } = useEditorMode();
-
   useSetupGlobalSocket();
   useSetupGlobalSocketForPage(pageId);
 
@@ -289,11 +287,6 @@ const Page: NextPage<Props> = (props: Props) => {
     }
   }, [props.currentPathname, router]);
 
-  const classNames: string[] = [];
-
-  const isSidebar = pagePath === '/Sidebar';
-  classNames.push(...getClassNamesByEditorMode(isSidebar));
-
   const isTopPagePath = isTopPage(pageWithMeta?.data.path ?? '');
 
   const title = generateCustomTitle(props, 'GROWI');