layout.ts 941 B

1234567891011121314151617181920212223242526
  1. import type { IPage } from '@growi/core';
  2. import { useIsContainerFluid } from '~/stores/context';
  3. import { useSWRxCurrentPage } from '~/stores/page';
  4. import { useEditorMode } from '~/stores/ui';
  5. export const useEditorModeClassName = (): string => {
  6. const { getClassNamesByEditorMode } = useEditorMode();
  7. return `${getClassNamesByEditorMode().join(' ') ?? ''}`;
  8. };
  9. export const useCurrentGrowiLayoutFluidClassName = (initialPage?: IPage): string => {
  10. const { data: currentPage } = useSWRxCurrentPage();
  11. const { data: dataIsContainerFluid } = useIsContainerFluid();
  12. const page = currentPage ?? initialPage;
  13. const isContainerFluidEachPage = page == null || !('expandContentWidth' in page)
  14. ? null
  15. : page.expandContentWidth;
  16. const isContainerFluidDefault = dataIsContainerFluid;
  17. const isContainerFluid = isContainerFluidEachPage ?? isContainerFluidDefault;
  18. return isContainerFluid ? 'growi-layout-fluid' : '';
  19. };