forked from primeroIMS/primero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.jsx
42 lines (31 loc) · 1.07 KB
/
component.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
import clsx from "clsx";
import PropTypes from "prop-types";
import { useThemeHelper } from "../../libs";
import { useApp } from "../application";
import css from "./styles.css";
const Component = ({ children, twoCol, fullWidthMobile }) => {
const { demo } = useApp();
const { mobileDisplay } = useThemeHelper();
const contentClasses = clsx({ [css.root]: true, [css.demo]: demo });
const twoColClasses = clsx({ [css.twoCol]: true, [css.demo]: demo });
const contentContainer = fullWidthMobile && mobileDisplay ? css.noWrap : css.wrap;
if (twoCol) {
return <div className={twoColClasses}>{children}</div>;
}
return (
<div className={contentClasses} data-testid="page-container">
<div className={contentContainer}>{children}</div>
</div>
);
};
Component.displayName = "PageContainer";
Component.defaultProps = {
fullWidthMobile: false
};
Component.propTypes = {
children: PropTypes.node.isRequired,
fullWidthMobile: PropTypes.bool,
twoCol: PropTypes.bool
};
export default Component;