2022-03-16 06:26:15 +00:00
|
|
|
import { FunctionComponent, ReactNode, useMemo } from "react";
|
2021-03-25 14:22:43 +00:00
|
|
|
import { Row } from "react-bootstrap";
|
|
|
|
import ContentHeaderButton, { ContentHeaderAsyncButton } from "./Button";
|
|
|
|
import ContentHeaderGroup from "./Group";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
scroll?: boolean;
|
|
|
|
className?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type Header = FunctionComponent<Props> & {
|
|
|
|
Button: typeof ContentHeaderButton;
|
|
|
|
AsyncButton: typeof ContentHeaderAsyncButton;
|
|
|
|
Group: typeof ContentHeaderGroup;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ContentHeader: Header = ({ children, scroll, className }) => {
|
|
|
|
const cls = useMemo(() => {
|
|
|
|
const rowCls = ["content-header", "bg-dark", "p-2"];
|
|
|
|
|
|
|
|
if (className !== undefined) {
|
|
|
|
rowCls.push(className);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scroll !== false) {
|
|
|
|
rowCls.push("scroll");
|
|
|
|
}
|
|
|
|
return rowCls.join(" ");
|
|
|
|
}, [scroll, className]);
|
|
|
|
|
2022-03-16 06:26:15 +00:00
|
|
|
let childItem: ReactNode;
|
2021-03-25 14:22:43 +00:00
|
|
|
|
|
|
|
if (scroll !== false) {
|
|
|
|
childItem = (
|
|
|
|
<div className="d-flex flex-nowrap flex-grow-1">{children}</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
childItem = children;
|
|
|
|
}
|
|
|
|
return <Row className={cls}>{childItem}</Row>;
|
|
|
|
};
|
|
|
|
|
|
|
|
ContentHeader.Button = ContentHeaderButton;
|
|
|
|
ContentHeader.Group = ContentHeaderGroup;
|
|
|
|
ContentHeader.AsyncButton = ContentHeaderAsyncButton;
|
|
|
|
|
|
|
|
export default ContentHeader;
|