2019-06-23 01:53:50 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
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';
|
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}>
|
2019-06-23 06:25:38 +00:00
|
|
|
{title && <h2 className={'text-neutral-300 mb-4 px-4'}>{title}</h2>}
|
2019-12-28 20:07:42 +00:00
|
|
|
{showFlashes &&
|
|
|
|
<FlashMessageRender
|
|
|
|
byKey={typeof showFlashes === 'string' ? showFlashes : undefined}
|
|
|
|
className={'mb-4'}
|
|
|
|
/>
|
|
|
|
}
|
2019-06-23 06:25:38 +00:00
|
|
|
<div className={classNames('bg-neutral-700 p-4 rounded shadow-lg relative', borderColor, {
|
2019-06-23 01:53:50 +00:00
|
|
|
'border-t-4': !!borderColor,
|
|
|
|
})}>
|
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;
|