ui/card frame: add support for arbitrary HTML attributes and event handlers

This commit is contained in:
Adorian Doran 2026-02-22 19:42:08 +02:00
parent ad2df957c7
commit e6e132e905

View File

@ -1,23 +1,24 @@
import "./Card.css"; import "./Card.css";
import { ComponentChildren, createContext } from "preact"; import { ComponentChildren, createContext } from "preact";
import { JSX } from "preact"; import { JSX, HTMLAttributes } from "preact";
import { useContext } from "preact/hooks"; import { useContext } from "preact/hooks";
import clsx from "clsx"; import clsx from "clsx";
// #region Card Frame // #region Card Frame
export interface CardFrameProps { export interface CardFrameProps extends HTMLAttributes<HTMLDivElement> {
className?: string; className?: string;
highlightOnHover?: boolean; highlightOnHover?: boolean;
children: ComponentChildren; children: ComponentChildren;
} }
export function CardFrame(props: CardFrameProps) { export function CardFrame({className, highlightOnHover, children, ...rest}: CardFrameProps) {
return <div className={clsx("tn-card-frame", props.className, { return <div {...rest}
"tn-card-highlight-on-hover": props.highlightOnHover className={clsx("tn-card-frame", className, {
"tn-card-highlight-on-hover": highlightOnHover
})}> })}>
{props.children} {children}
</div>; </div>;
} }