summaryrefslogtreecommitdiffstats
path: root/src/ui/objects/ActionButton.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/ActionButton.tsx
downloadcorvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.gz
corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.bz2
corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.zip
Init
Diffstat (limited to 'src/ui/objects/ActionButton.tsx')
-rw-r--r--src/ui/objects/ActionButton.tsx61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/ui/objects/ActionButton.tsx b/src/ui/objects/ActionButton.tsx
new file mode 100644
index 0000000..76f859f
--- /dev/null
+++ b/src/ui/objects/ActionButton.tsx
@@ -0,0 +1,61 @@
1import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts";
2
3export type Props<Tag extends HTMLTag> = Polymorphic<{
4 "as"?: Tag;
5 "label-as"?: string;
6 "pill"?: boolean;
7 "icon"?: JSX.Element;
8 "pre"?: JSX.Element;
9 "post"?: JSX.Element;
10 "highlighted"?: boolean;
11 "selected"?: boolean;
12 "wide"?: boolean;
13 "justify"?: boolean;
14 "align-block"?: boolean;
15 "level"?: "button" | "badge" | "quiet";
16 "variant"?: "accent" | "positive" | "negative" | "warning" | "static-black" | "static-white";
17 "size"?: "xs" | "sm" | "lg" | "xl";
18 "children"?: JSX.Element;
19}>;
20
21export const ActionButton = <T extends HTMLTag = "a">({
22 children,
23 as: Tag = "a" as T,
24 "label-as": Label = "span",
25 pill,
26 pre,
27 post,
28 wide,
29 justify,
30 icon,
31 "align-block": alignBlock,
32 highlighted,
33 selected,
34 level,
35 variant,
36 size,
37 class: cls,
38 ...props
39}: Props<T>) => (
40 <Tag
41 class:list={[
42 "o-button",
43 {
44 "o-button--pill": pill,
45 "o-button--wide": wide,
46 "o-button--justify": justify,
47 "o-button--icon": icon,
48 "o-button--align-block": alignBlock,
49 "is-highlighted": highlighted,
50 "is-selected": selected,
51 [`o-button--${level}`]: level && level !== "button",
52 [`o-button--${variant}`]: variant,
53 [`o-button--${size}`]: size,
54 },
55 cls,
56 ]}
57 {...props}
58 >
59 {pre} {icon ?? <Label class="o-button__label">{children}</Label>} {post}
60 </Tag>
61);