new-personal-site/components/lib/elements/Card.tsx

46 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-12-09 15:36:17 +00:00
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General Card
* @className_wrapper twui-card
*/
export default function Card({
href,
variant,
linkProps,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
variant?: "normal";
href?: string;
linkProps?: DetailedHTMLProps<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>;
}) {
const component = (
<div
{...props}
className={twMerge(
"flex flex-row items-center p-4 rounded bg-white dark:bg-white/10",
"border border-slate-200 dark:border-white/10 border-solid",
href ? "hover:bg-slate-100 dark:hover:bg-white/30" : "",
"twui-card",
props.className
)}
>
{props.children}
</div>
);
if (href) {
return (
<a href={href} {...linkProps}>
{component}
</a>
);
}
return component;
}