import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts";
export type Props = Polymorphic<{
as: Tag;
level?: "xxl" | "xl" | "lg" | "md" | "sm" | "xs";
variant?: "static-black" | "static-white";
display?: boolean;
highlight?: boolean;
children?: JSX.Element;
}>;
const levelTagMap = {
lg: "h3",
md: "h4",
sm: "h5",
xl: "h2",
xs: "h6",
xxl: "h1",
} as const;
export const Heading = ({
as,
children,
display,
level,
variant,
highlight,
class: cls,
...props
}: Props) => {
const Tag = as ?? (level ? levelTagMap[level] : "strong");
return (
{highlight ? {children} : children}
);
};