FPSMS-frontend
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

73 wiersze
2.2 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 { isFullBleedMainRoute } from "@/app/(main)/isFullBleedMainRoute";
  6. import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig";
  7. const MAIN_SURFACE = "min-h-screen bg-slate-50 dark:bg-slate-900";
  8. /**
  9. * Workbench route: fixed height under the AppBar (`100dvh` minus toolbar min-height).
  10. * Avoids `min-h-screen` on `<main>`, which would stack below the bar and introduce body scroll.
  11. */
  12. /** Height lives in `sx` when full-bleed workbench so it matches MUI flex chain (avoids Tailwind vs % rounding gaps). */
  13. const WORKBENCH_MAIN = "bg-slate-50 dark:bg-slate-900 p-0 overflow-hidden";
  14. const MAIN_PADDING = "p-4 sm:p-4 md:p-6 lg:p-8";
  15. /**
  16. * Wraps authenticated app content in `<main>` with responsive padding.
  17. *
  18. * For the PO Workbench route, padding is removed so the grid can use the full content width
  19. * without applying compensating negative margins.
  20. */
  21. export default function MainContentArea({
  22. children,
  23. }: {
  24. children: React.ReactNode;
  25. }) {
  26. const pathname = usePathname();
  27. /** True when the active route is PO Workbench (full-bleed main area). */
  28. const fullBleedWorkbench = isFullBleedMainRoute(pathname);
  29. return (
  30. <Box
  31. component="main"
  32. sx={{
  33. marginInlineStart: { xs: 0, xl: NAVIGATION_CONTENT_WIDTH },
  34. ...(fullBleedWorkbench
  35. ? {
  36. display: "flex",
  37. flexDirection: "column",
  38. boxSizing: "border-box",
  39. flex: 1,
  40. minHeight: 0,
  41. height: "100%",
  42. }
  43. : {}),
  44. }}
  45. className={
  46. fullBleedWorkbench ? WORKBENCH_MAIN : `${MAIN_SURFACE} ${MAIN_PADDING}`
  47. }
  48. >
  49. <Stack
  50. spacing={fullBleedWorkbench ? 0 : 2}
  51. sx={
  52. fullBleedWorkbench
  53. ? {
  54. flex: 1,
  55. minHeight: 0,
  56. height: "100%",
  57. overflow: "hidden",
  58. display: "flex",
  59. flexDirection: "column",
  60. }
  61. : undefined
  62. }
  63. >
  64. {children}
  65. </Stack>
  66. </Box>
  67. );
  68. }