diff options
Diffstat (limited to 'src/ui/layouts/HList.tsx')
| -rw-r--r-- | src/ui/layouts/HList.tsx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ui/layouts/HList.tsx b/src/ui/layouts/HList.tsx new file mode 100644 index 0000000..c1d870a --- /dev/null +++ b/src/ui/layouts/HList.tsx | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts"; | ||
| 2 | |||
| 3 | import type { Props as ActionButtonProps } from "../objects/ActionButton.tsx"; | ||
| 4 | |||
| 5 | export type Props<Tag extends HTMLTag> = Polymorphic<{ | ||
| 6 | "as"?: Tag; | ||
| 7 | "pill"?: boolean; | ||
| 8 | "icon"?: boolean; | ||
| 9 | "separated"?: boolean; | ||
| 10 | "size"?: "gapless" | "sm" | "lg" | "xl"; | ||
| 11 | "buttons-size"?: ActionButtonProps<Tag>["size"]; | ||
| 12 | "buttons"?: boolean; | ||
| 13 | }>; | ||
| 14 | |||
| 15 | export const HList = <T extends HTMLTag = "ul">({ | ||
| 16 | as: Tag = "ul" as T, | ||
| 17 | pill, | ||
| 18 | icon, | ||
| 19 | separated, | ||
| 20 | size, | ||
| 21 | "buttons-size": buttonsSize, | ||
| 22 | buttons, | ||
| 23 | class: cls, | ||
| 24 | ...props | ||
| 25 | }: Props<T>) => ( | ||
| 26 | <Tag | ||
| 27 | class:list={[ | ||
| 28 | "l-hlist", | ||
| 29 | { | ||
| 30 | "l-hlist--pill": pill, | ||
| 31 | "l-hlist--icon": icon, | ||
| 32 | "l-hlist--separated": separated, | ||
| 33 | [`l-hlist--${size}`]: size, | ||
| 34 | [`l-hlist--buttons-${buttonsSize}`]: buttonsSize, | ||
| 35 | "l-hlist--buttons": buttons, | ||
| 36 | }, | ||
| 37 | "js-keyboard-nav", | ||
| 38 | cls, | ||
| 39 | ]} | ||
| 40 | data-keyboard-nav-item="li > :first-child" | ||
| 41 | data-keyboard-nav-mode="nav" | ||
| 42 | {...props} | ||
| 43 | /> | ||
| 44 | ); | ||
