FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 

63 строки
1.9 KiB

  1. "use client";
  2. import Box from "@mui/material/Box";
  3. import Stack from "@mui/material/Stack";
  4. import { usePathname } from "next/navigation";
  5. import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig";
  6. const MAIN_SURFACE = "min-h-screen bg-slate-50 dark:bg-slate-900";
  7. /**
  8. * Workbench route: fixed height under the AppBar (`100dvh` minus toolbar min-height).
  9. * Avoids `min-h-screen` on `<main>`, which would stack below the bar and introduce body scroll.
  10. */
  11. const WORKBENCH_MAIN =
  12. "bg-slate-50 dark:bg-slate-900 p-0 overflow-hidden h-[calc(100dvh-56px)] max-h-[calc(100dvh-56px)] sm:h-[calc(100dvh-64px)] sm:max-h-[calc(100dvh-64px)]";
  13. const MAIN_PADDING = "p-4 sm:p-4 md:p-6 lg:p-8";
  14. /** Returns true when `pathname` is `/po/workbench` or a nested path under it. */
  15. function isPoWorkbenchRoute(pathname: string | null): boolean {
  16. if (!pathname) return false;
  17. return pathname === "/po/workbench" || pathname.startsWith("/po/workbench/");
  18. }
  19. /**
  20. * Wraps authenticated app content in `<main>` with responsive padding.
  21. *
  22. * For the PO Workbench route, padding is removed so the grid can use the full content width
  23. * without applying compensating negative margins.
  24. */
  25. export default function MainContentArea({
  26. children,
  27. }: {
  28. children: React.ReactNode;
  29. }) {
  30. const pathname = usePathname();
  31. /** True when the active route is PO Workbench (full-bleed main area). */
  32. const fullBleedWorkbench = isPoWorkbenchRoute(pathname);
  33. return (
  34. <Box
  35. component="main"
  36. sx={{
  37. marginInlineStart: { xs: 0, xl: NAVIGATION_CONTENT_WIDTH },
  38. }}
  39. className={
  40. fullBleedWorkbench
  41. ? WORKBENCH_MAIN
  42. : `${MAIN_SURFACE} ${MAIN_PADDING}`
  43. }
  44. >
  45. <Stack
  46. spacing={fullBleedWorkbench ? 0 : 2}
  47. sx={
  48. fullBleedWorkbench
  49. ? { height: "100%", minHeight: 0, overflow: "hidden" }
  50. : undefined
  51. }
  52. >
  53. {children}
  54. </Stack>
  55. </Box>
  56. );
  57. }