2020-07-03 22:37:26 +00:00
|
|
|
import 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
|
|
|
|
|
|
|
type Props = Readonly<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
|
|
|
title?: string;
|
|
|
|
borderColor?: string;
|
2019-06-23 06:45:09 +00:00
|
|
|
showFlashes?: string | boolean;
|
2020-03-26 04:58:37 +00:00
|
|
|
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>}
|
2019-12-28 20:07:42 +00:00
|
|
|
{showFlashes &&
|
|
|
|
<FlashMessageRender
|
|
|
|
byKey={typeof showFlashes === 'string' ? showFlashes : undefined}
|
2020-07-03 22:37:26 +00:00
|
|
|
css={tw`mb-4`}
|
2019-12-28 20:07:42 +00:00
|
|
|
/>
|
|
|
|
}
|
2020-07-03 22:37:26 +00:00
|
|
|
<div
|
|
|
|
css={[
|
|
|
|
tw`bg-neutral-700 p-4 rounded shadow-lg relative`,
|
|
|
|
!!borderColor && tw`border-t-4`,
|
|
|
|
]}
|
|
|
|
>
|
2020-03-26 04:58:37 +00:00
|
|
|
<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;
|