2020-09-23 04:41:35 +00:00
|
|
|
import React, { memo } from 'react';
|
2019-09-29 20:23:15 +00:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
2020-07-04 22:40:41 +00:00
|
|
|
import tw from 'twin.macro';
|
2020-09-23 04:41:35 +00:00
|
|
|
import isEqual from 'react-fast-compare';
|
2019-09-29 20:23:15 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
icon?: IconProp;
|
2020-03-26 04:58:37 +00:00
|
|
|
title: string | React.ReactNode;
|
2019-09-29 20:23:15 +00:00
|
|
|
className?: string;
|
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2020-02-08 23:23:08 +00:00
|
|
|
const TitledGreyBox = ({ icon, title, children, className }: Props) => (
|
2020-07-04 22:40:41 +00:00
|
|
|
<div css={tw`rounded shadow-md bg-neutral-700`} className={className}>
|
|
|
|
<div css={tw`bg-neutral-900 rounded-t p-3 border-b border-black`}>
|
2022-06-26 19:13:52 +00:00
|
|
|
{typeof title === 'string' ? (
|
2020-07-04 22:40:41 +00:00
|
|
|
<p css={tw`text-sm uppercase`}>
|
2022-06-26 19:13:52 +00:00
|
|
|
{icon && <FontAwesomeIcon icon={icon} css={tw`mr-2 text-neutral-300`} />}
|
|
|
|
{title}
|
2020-03-26 04:58:37 +00:00
|
|
|
</p>
|
2022-06-26 19:13:52 +00:00
|
|
|
) : (
|
2020-03-26 04:58:37 +00:00
|
|
|
title
|
2022-06-26 19:13:52 +00:00
|
|
|
)}
|
2019-09-29 20:23:15 +00:00
|
|
|
</div>
|
2022-06-26 19:13:52 +00:00
|
|
|
<div css={tw`p-3`}>{children}</div>
|
2019-09-29 20:23:15 +00:00
|
|
|
</div>
|
|
|
|
);
|
2020-02-08 23:23:08 +00:00
|
|
|
|
2020-09-23 04:41:35 +00:00
|
|
|
export default memo(TitledGreyBox, isEqual);
|