-
Notifications
You must be signed in to change notification settings - Fork 194
/
Container.tsx
43 lines (39 loc) · 948 Bytes
/
Container.tsx
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
43
type MaxWidth = "sm" | "md" | "lg" | "xl" | "2xl";
type Props = {
children: React.ReactNode;
justifyBetween?: boolean;
maxWidth?: MaxWidth;
};
function Container({
children,
justifyBetween = false,
maxWidth = "lg",
}: Props) {
// Avoid dynamically created class strings as PurgeCSS doesn't understand this.
const getMaxWidthClass = (maxWidth: MaxWidth) => {
switch (maxWidth) {
case "sm":
return "max-w-screen-sm";
case "md":
return "max-w-screen-md";
case "lg":
return "max-w-screen-lg";
case "xl":
return "max-w-screen-xl";
case "2xl":
return "max-w-screen-2xl";
}
};
return (
<div
className={`container mx-auto px-4 pb-4 ${getMaxWidthClass(maxWidth)} ${
justifyBetween
? "h-full flex flex-col justify-between no-scrollbar"
: ""
}`}
>
{children}
</div>
);
}
export default Container;