PageViewLayout.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import type { JSX, ReactNode } from 'react';
  2. // biome-ignore lint/style/noRestrictedImports: ignore
  3. import { usePrintMode } from '~/client/services/use-print-mode';
  4. import styles from './PageViewLayout.module.scss';
  5. const pageViewLayoutClass = styles['page-view-layout'] ?? '';
  6. const _fluidLayoutClass = styles['fluid-layout'] ?? '';
  7. type Props = {
  8. className?: string;
  9. children?: ReactNode;
  10. headerContents?: ReactNode;
  11. sideContents?: ReactNode;
  12. footerContents?: ReactNode;
  13. expandContentWidth?: boolean;
  14. };
  15. export const PageViewLayout = (props: Props): JSX.Element => {
  16. const {
  17. className,
  18. children,
  19. headerContents,
  20. sideContents,
  21. footerContents,
  22. expandContentWidth,
  23. } = props;
  24. const isPrinting = usePrintMode();
  25. const fluidLayoutClass = expandContentWidth ? _fluidLayoutClass : '';
  26. return (
  27. <>
  28. <div
  29. className={`main ${className} ${pageViewLayoutClass} ${fluidLayoutClass} flex-expand-vert ps-sidebar`}
  30. >
  31. <div className="container-lg wide-gutter-x-lg grw-container-convertible flex-expand-vert gap-4">
  32. {headerContents != null && headerContents}
  33. {!isPrinting && sideContents != null ? (
  34. <div className="flex-expand-horiz gap-3 z-0">
  35. <div className="flex-expand-vert flex-basis-0 mw-0">
  36. {children}
  37. </div>
  38. <div
  39. className="grw-side-contents-container col-lg-3 d-edit-none"
  40. data-vrt-blackout-side-contents
  41. >
  42. <div className="grw-side-contents-sticky-container">
  43. {sideContents}
  44. </div>
  45. </div>
  46. </div>
  47. ) : (
  48. <div className="z-0">{children}</div>
  49. )}
  50. </div>
  51. </div>
  52. {footerContents != null && (
  53. <footer
  54. className={`footer d-edit-none container-lg wide-gutter-x-lg ${fluidLayoutClass}`}
  55. >
  56. {footerContents}
  57. </footer>
  58. )}
  59. </>
  60. );
  61. };