2021-01-08 17:02:49 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import tw from 'twin.macro';
|
|
|
|
import isEqual from 'react-fast-compare';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
icon?: IconProp;
|
|
|
|
title: string | React.ReactNode;
|
|
|
|
className?: string;
|
2021-05-20 22:00:46 +00:00
|
|
|
padding?: boolean;
|
2021-01-08 17:02:49 +00:00
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2021-05-20 22:00:46 +00:00
|
|
|
const AdminBox = ({ icon, title, className, padding, children }: Props) => {
|
|
|
|
if (padding === undefined) {
|
|
|
|
padding = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div css={tw`rounded shadow-md bg-neutral-700`} className={className}>
|
2021-09-16 03:19:39 +00:00
|
|
|
<div css={tw`bg-neutral-900 rounded-t px-4 py-3 border-b border-black`}>
|
2021-05-20 22:00:46 +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
|
|
|
|
}
|
|
|
|
</div>
|
2021-09-16 03:19:39 +00:00
|
|
|
<div css={padding ? tw`px-4 py-3` : undefined}>
|
2021-05-20 22:00:46 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
2021-01-08 17:02:49 +00:00
|
|
|
</div>
|
2021-05-20 22:00:46 +00:00
|
|
|
);
|
|
|
|
};
|
2021-01-08 17:02:49 +00:00
|
|
|
|
|
|
|
export default memo(AdminBox, isEqual);
|