summaryrefslogtreecommitdiffstats
path: root/src/ui/layouts/HList.tsx
blob: c1d870a46748af2f5f4e59d2390f5b6359c41eb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts";

import type { Props as ActionButtonProps } from "../objects/ActionButton.tsx";

export type Props<Tag extends HTMLTag> = Polymorphic<{
	"as"?: Tag;
	"pill"?: boolean;
	"icon"?: boolean;
	"separated"?: boolean;
	"size"?: "gapless" | "sm" | "lg" | "xl";
	"buttons-size"?: ActionButtonProps<Tag>["size"];
	"buttons"?: boolean;
}>;

export const HList = <T extends HTMLTag = "ul">({
	as: Tag = "ul" as T,
	pill,
	icon,
	separated,
	size,
	"buttons-size": buttonsSize,
	buttons,
	class: cls,
	...props
}: Props<T>) => (
	<Tag
		class:list={[
			"l-hlist",
			{
				"l-hlist--pill": pill,
				"l-hlist--icon": icon,
				"l-hlist--separated": separated,
				[`l-hlist--${size}`]: size,
				[`l-hlist--buttons-${buttonsSize}`]: buttonsSize,
				"l-hlist--buttons": buttons,
			},
			"js-keyboard-nav",
			cls,
		]}
		data-keyboard-nav-item="li > :first-child"
		data-keyboard-nav-mode="nav"
		{...props}
	/>
);