summaryrefslogtreecommitdiffstats
path: root/src/ui/objects/CollapseCard.tsx
blob: 27e1ce2dbc075ab9139a8090d249c75ad091988b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Card, type Props as CardProps } from "./Card.tsx";
import { CardBody } from "./CardBody.tsx";
import { Heading } from "./Heading.tsx";

export type Props = CardProps<"details"> & {
	"heading-level": "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
	"title"?: JSX.Element;
	"header"?: JSX.Element;
};

export const CollapseCard = ({
	"heading-level": headingLevel,
	children,
	title,
	header,
	...props
}: Props) => (
	<Card as="details" {...props}>
		<CardBody as="summary">
			<Heading as={headingLevel} class="u-mbs-0" level="lg">
				{title}
			</Heading>
			{header}
		</CardBody>
		<CardBody>{children}</CardBody>
	</Card>
);