2021-02-02 05:28:25 +01:00
|
|
|
import { h } from 'preact';
|
|
|
|
import Button from './Button';
|
|
|
|
import Heading from './Heading';
|
|
|
|
|
|
|
|
export default function Box({
|
|
|
|
buttons = [],
|
|
|
|
className = '',
|
|
|
|
content,
|
2021-02-05 00:19:47 +01:00
|
|
|
elevated = true,
|
2021-02-02 05:28:25 +01:00
|
|
|
header,
|
|
|
|
href,
|
|
|
|
icons,
|
|
|
|
media = null,
|
|
|
|
subheader,
|
|
|
|
supportingText,
|
|
|
|
...props
|
|
|
|
}) {
|
|
|
|
const Element = href ? 'a' : 'div';
|
|
|
|
|
2021-02-05 01:18:15 +01:00
|
|
|
const typeClasses = elevated
|
|
|
|
? 'shadow-md hover:shadow-lg transition-shadow'
|
|
|
|
: 'border border-gray-200 dark:border-gray-700';
|
2021-02-05 00:19:47 +01:00
|
|
|
|
2021-02-02 05:28:25 +01:00
|
|
|
return (
|
2021-02-05 00:19:47 +01:00
|
|
|
<div className={`bg-white dark:bg-gray-800 rounded-lg overflow-hidden ${typeClasses} ${className}`}>
|
|
|
|
{media || header ? (
|
|
|
|
<Element href={href} {...props}>
|
|
|
|
{media}
|
2021-02-09 20:35:33 +01:00
|
|
|
<div className="p-4 pb-2">{header ? <Heading size="base">{header}</Heading> : null}</div>
|
2021-02-05 00:19:47 +01:00
|
|
|
</Element>
|
|
|
|
) : null}
|
2021-02-02 05:28:25 +01:00
|
|
|
{buttons.length || content ? (
|
2021-02-09 20:35:33 +01:00
|
|
|
<div className="pl-4 pb-2">
|
2021-02-02 05:28:25 +01:00
|
|
|
{content || null}
|
|
|
|
{buttons.length ? (
|
2021-02-09 20:35:33 +01:00
|
|
|
<div className="flex space-x-4 -ml-2">
|
2021-02-02 05:28:25 +01:00
|
|
|
{buttons.map(({ name, href }) => (
|
|
|
|
<Button key={name} href={href} type="text">
|
|
|
|
{name}
|
|
|
|
</Button>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|