frigate/web/src/components/Card.jsx

53 lines
1.5 KiB
React
Raw Normal View History

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