Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/components/elements/ContentBox.tsx
7461 views
1
import React from 'react';
2
import FlashMessageRender from '@/components/FlashMessageRender';
3
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
4
import tw from 'twin.macro';
5
6
type Props = Readonly<
7
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
8
title?: string;
9
borderColor?: string;
10
showFlashes?: string | boolean;
11
showLoadingOverlay?: boolean;
12
}
13
>;
14
15
const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => (
16
<div {...props}>
17
{title && <h2 css={tw`text-neutral-300 mb-4 px-4 text-2xl`}>{title}</h2>}
18
{showFlashes && (
19
<FlashMessageRender byKey={typeof showFlashes === 'string' ? showFlashes : undefined} css={tw`mb-4`} />
20
)}
21
<div css={[tw`bg-neutral-700 p-4 rounded shadow-lg relative`, !!borderColor && tw`border-t-4`]}>
22
<SpinnerOverlay visible={showLoadingOverlay || false} />
23
{children}
24
</div>
25
</div>
26
);
27
28
export default ContentBox;
29
30