2020-07-03 15:37:26 -07:00
|
|
|
import React from 'react';
|
2026-10-12 09:04:03 -04:00
|
|
|
import Card from '@/components/elements/Card';
|
2026-10-05 18:10:18 -04:00
|
|
|
import { cn } from '@/lib/cn';
|
|
|
|
|
import { sectionTitleClass } from '@/components/ui/typography';
|
2019-06-22 18:53:50 -07:00
|
|
|
|
2022-06-26 15:13:52 -04:00
|
|
|
type Props = Readonly<
|
|
|
|
|
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
|
|
|
|
title?: string;
|
|
|
|
|
borderColor?: string;
|
|
|
|
|
showLoadingOverlay?: boolean;
|
|
|
|
|
}
|
|
|
|
|
>;
|
2019-06-22 18:53:50 -07:00
|
|
|
|
2026-10-12 09:04:03 -04:00
|
|
|
/** A section title above a plain `Card`. */
|
2026-10-05 18:10:18 -04:00
|
|
|
const ContentBox = ({ title, borderColor, showLoadingOverlay, children, ...props }: Props) => (
|
2019-06-22 18:53:50 -07:00
|
|
|
<div {...props}>
|
2026-10-05 18:10:18 -04:00
|
|
|
{title && <h2 className={cn(sectionTitleClass, 'mb-4 px-4')}>{title}</h2>}
|
2026-10-12 09:04:03 -04:00
|
|
|
<Card loading={showLoadingOverlay} className={borderColor ? 'border-t-4' : undefined}>
|
2019-06-22 18:53:50 -07:00
|
|
|
{children}
|
2026-10-12 09:04:03 -04:00
|
|
|
</Card>
|
2019-06-22 18:53:50 -07:00
|
|
|
</div>
|
|
|
|
|
);
|
2020-02-08 15:23:08 -08:00
|
|
|
|
|
|
|
|
export default ContentBox;
|