shak3008's picture
feat: render in-page interactive elements as Links to support right-click open in new tab
46cb663
Raw
History Blame Contribute Delete
1.11 kB
import { Link } from "react-router-dom";
import "./Card.css";
export function Card({ children, interactive = false, padded = true, className = "", to, ...props }) {
const Component = to ? Link : "div";
return (
<Component
to={to}
className={`dw-card ${interactive || to ? "dw-card--interactive" : ""} ${
padded ? "dw-card--padded" : ""
} ${className}`}
{...props}
>
{children}
</Component>
);
}
export function CardHeader({ title, subtitle, action, className = "" }) {
return (
<div className={`dw-card__header ${className}`}>
<div className="dw-card__header-text">
{title && <h3 className="dw-card__title">{title}</h3>}
{subtitle && <p className="dw-card__subtitle">{subtitle}</p>}
</div>
{action && <div className="dw-card__header-action">{action}</div>}
</div>
);
}
export function CardBody({ children, className = "" }) {
return <div className={`dw-card__body ${className}`}>{children}</div>;
}