cs-2022-class-profile/components/SideComponentWrapper.tsx

43 lines
1.1 KiB
TypeScript

import React from "react";
import { useIsMobile } from "utils/isMobile";
import styles from "./SideComponentWrapper.module.css";
type ComponentWrapperProps = {
children: React.ReactNode;
heading: string;
body: string;
rightAligned?: boolean;
};
export default function SideComponentWrapper({
heading,
body,
children,
rightAligned = false,
}: ComponentWrapperProps) {
const isMobile = useIsMobile();
return (
<div className={rightAligned ? styles.wrapperRight : styles.wrapperLeft}>
{rightAligned && !isMobile ? (
<>
<div className={styles.graphWrapper}>{children}</div>
<div className={styles.textWrapper}>
<h3 className={styles.heading}>{heading}</h3>
<p className={styles.body}>{body}</p>
</div>
</>
) : (
<>
<div className={styles.textWrapper}>
<h3 className={styles.heading}>{heading}</h3>
<p className={styles.body}>{body}</p>
</div>
<div className={styles.graphWrapper}>{children}</div>
</>
)}
</div>
);
}