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

43 lines
910 B
TypeScript
Raw Normal View History

2022-08-08 23:15:38 -04:00
import React from "react";
2022-08-15 21:30:21 -04:00
import styles from "./ComponentWrapper.module.css";
type AlignOption = "left" | "center" | "right";
2022-08-08 23:15:38 -04:00
type ComponentWrapperProps = {
children: React.ReactNode;
heading: string;
2022-08-31 07:25:56 -04:00
bodyText: string;
2022-08-15 21:30:21 -04:00
align?: AlignOption;
2022-08-12 00:20:55 -04:00
noBackground?: boolean;
2022-08-08 23:15:38 -04:00
};
2022-08-15 21:30:21 -04:00
export function ComponentWrapper({
2022-08-08 23:15:38 -04:00
heading,
2022-08-31 07:25:56 -04:00
bodyText,
2022-08-08 23:15:38 -04:00
children,
2022-08-12 00:41:14 -04:00
align = "left",
2022-08-12 00:20:55 -04:00
noBackground = false,
2022-08-08 23:15:38 -04:00
}: ComponentWrapperProps) {
2022-08-15 21:30:21 -04:00
const alignClasses: { [key in AlignOption]: string } = {
left: styles.wrapperLeft,
center: styles.wrapperCenter,
right: styles.wrapperRight,
};
2022-08-08 23:15:38 -04:00
return (
2022-08-12 00:20:55 -04:00
<div
2022-08-15 21:30:21 -04:00
className={`
${alignClasses[align]}
${noBackground ? styles.noBackground : ""}
`}
2022-08-12 00:20:55 -04:00
>
<div className={styles.internalWrapper}>
<h3>{heading}</h3>
2022-08-31 07:25:56 -04:00
<p>{bodyText}</p>
2022-08-12 00:20:55 -04:00
</div>
<div className={styles.internalWrapper}>{children}</div>
2022-08-08 23:15:38 -04:00
</div>
);
}