2022-11-25 20:25:03 +00:00
|
|
|
import * as React from 'react';
|
2019-06-23 06:45:09 +00:00
|
|
|
import FlashMessageRender from '@/components/FlashMessageRender';
|
2020-03-26 04:58:37 +00:00
|
|
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
2020-07-03 22:37:26 +00:00
|
|
|
import tw from 'twin.macro';
|
2019-06-23 01:53:50 +00:00
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
type Props = Readonly<
|
|
|
|
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
|
|
|
title?: string;
|
|
|
|
borderColor?: string;
|
|
|
|
showFlashes?: string | boolean;
|
|
|
|
showLoadingOverlay?: boolean;
|
|
|
|
}
|
|
|
|
>;
|
2019-06-23 01:53:50 +00:00
|
|
|
|
2020-03-26 04:58:37 +00:00
|
|
|
const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => (
|
2019-06-23 01:53:50 +00:00
|
|
|
<div {...props}>
|
2020-07-03 22:37:26 +00:00
|
|
|
{title && <h2 css={tw`text-neutral-300 mb-4 px-4 text-2xl`}>{title}</h2>}
|
2022-06-26 19:13:52 +00:00
|
|
|
{showFlashes && (
|
|
|
|
<FlashMessageRender byKey={typeof showFlashes === 'string' ? showFlashes : undefined} css={tw`mb-4`} />
|
|
|
|
)}
|
|
|
|
<div css={[tw`bg-neutral-700 p-4 rounded shadow-lg relative`, !!borderColor && tw`border-t-4`]}>
|
|
|
|
<SpinnerOverlay visible={showLoadingOverlay || false} />
|
2019-06-23 01:53:50 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2020-02-08 23:23:08 +00:00
|
|
|
|
|
|
|
export default ContentBox;
|