summaryrefslogtreecommitdiffstats
path: root/src/ui/objects/Heading.tsx
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2026-07-22 19:40:59 +0200
committerVolpeon <git@volpeon.ink>2026-07-22 19:40:59 +0200
commitc1e28224aa2e1450031669d9a7e359b63e04687d (patch)
tree68f3d8905c763a91f68001d868197effa92adafa /src/ui/objects/Heading.tsx
downloadcorvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.gz
corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.bz2
corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.zip
Init
Diffstat (limited to 'src/ui/objects/Heading.tsx')
-rw-r--r--src/ui/objects/Heading.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ui/objects/Heading.tsx b/src/ui/objects/Heading.tsx
new file mode 100644
index 0000000..089de3a
--- /dev/null
+++ b/src/ui/objects/Heading.tsx
@@ -0,0 +1,49 @@
1import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts";
2
3export type Props<Tag extends HTMLTag> = Polymorphic<{
4 as: Tag;
5 level?: "xxl" | "xl" | "lg" | "md" | "sm" | "xs";
6 variant?: "static-black" | "static-white";
7 display?: boolean;
8 highlight?: boolean;
9 children?: JSX.Element;
10}>;
11
12const levelTagMap = {
13 lg: "h3",
14 md: "h4",
15 sm: "h5",
16 xl: "h2",
17 xs: "h6",
18 xxl: "h1",
19} as const;
20
21export const Heading = <T extends HTMLTag = "div">({
22 as,
23 children,
24 display,
25 level,
26 variant,
27 highlight,
28 class: cls,
29 ...props
30}: Props<T>) => {
31 const Tag = as ?? (level ? levelTagMap[level] : "strong");
32 return (
33 <Tag
34 class:list={[
35 "o-heading",
36 {
37 [`o-heading--${level}`]: level,
38 [`o-heading--${variant}`]: variant,
39 "o-heading--display": display,
40 "u-c-heading": Tag === "strong",
41 },
42 cls,
43 ]}
44 {...props}
45 >
46 {highlight ? <span class="o-heading__highlight">{children}</span> : children}
47 </Tag>
48 );
49};