2021-10-03 23:24:23 +00:00
|
|
|
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';
|
2021-10-03 23:24:23 +00:00
|
|
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
2021-01-08 17:02:49 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
icon?: IconProp;
|
2021-10-03 23:24:23 +00:00
|
|
|
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;
|
2021-10-03 22:06:48 +00:00
|
|
|
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) => (
|
2021-10-03 23:24:23 +00:00
|
|
|
<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`}>
|
2021-10-03 23:24:23 +00:00
|
|
|
{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` ]}>
|
2021-10-03 23:24:23 +00:00
|
|
|
{children}
|
2021-01-08 17:02:49 +00:00
|
|
|
</div>
|
2021-10-03 23:24:23 +00:00
|
|
|
</div>
|
|
|
|
);
|
2021-01-08 17:02:49 +00:00
|
|
|
|
2021-10-03 23:24:23 +00:00
|
|
|
export default AdminBox;
|