misc_pterodactyl-panel/resources/scripts/components/admin/AdminBox.tsx

37 lines
1.2 KiB
TypeScript
Raw Normal View History

import React from 'react';
2021-01-08 17:02:49 +00:00
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import tw from 'twin.macro';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
2021-01-08 17:02:49 +00:00
interface Props {
icon?: IconProp;
isLoading?: boolean;
2021-01-08 17:02:49 +00:00
title: string | React.ReactNode;
className?: string;
2021-10-04 00:26:44 +00:00
noPadding?: boolean;
2021-01-08 17:02:49 +00:00
children: React.ReactNode;
button?: React.ReactNode;
2021-01-08 17:02:49 +00:00
}
2021-10-04 00:26:44 +00:00
const AdminBox = ({ icon, title, className, isLoading, children, button, noPadding }: Props) => (
<div css={tw`relative rounded shadow-md bg-neutral-700`} className={className}>
<SpinnerOverlay visible={isLoading || false}/>
2021-10-04 00:26:44 +00:00
<div css={tw`flex flex-row bg-neutral-900 rounded-t px-4 xl:px-5 py-3 border-b border-black`}>
{typeof title === 'string' ?
<p css={tw`text-sm uppercase`}>
{icon && <FontAwesomeIcon icon={icon} css={tw`mr-2 text-neutral-300`}/>}{title}
</p>
:
title
}
{button}
</div>
2021-10-04 00:26:44 +00:00
<div css={[ !noPadding && tw`px-4 xl:px-5 py-5` ]}>
{children}
2021-01-08 17:02:49 +00:00
</div>
</div>
);
2021-01-08 17:02:49 +00:00
export default AdminBox;