summaryrefslogtreecommitdiffstats
path: root/src/ui/layouts/CardList.tsx
blob: 96ae642eaece2149e1842b110a7b1b1cdbd68f9f (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
45
46
47
48
49
50
51
52
import type { HTMLAttributes } from "corvos/plugins/jsx.ts";

export type Props = HTMLAttributes<"ul"> & {
	"layout"?:
		| "merge"
		| "grid"
		| "grid-sm"
		| "grid-xs"
		| "flex"
		| "flex-sm"
		| "flex-xs"
		| "masonry"
		| "masonry-h"
		| "masonry-h-sm";
	"quiet"?: boolean;
	"border"?: boolean;
	"interactive"?: boolean;
	"no-shadow"?: boolean;
	"no-flush"?: boolean;
	"keyboard-nav"?: boolean;
};

export const CardList = ({
	layout,
	quiet,
	border,
	interactive,
	"no-shadow": noShadow,
	"no-flush": noFlush,
	"keyboard-nav": keyboardNav,
	class: cls,
	...props
}: Props) => (
	<div
		class:list={[
			"l-card-list",
			{
				[`l-card-list--${layout}`]: layout,
				"l-card-list--interactive": interactive,
				"l-card-list--no-flush": noFlush,
				"l-card-list--quiet": quiet,
				"l-card-list--borderless": !border,
				"l-card-list--shadow": layout === "merge" && !noShadow,
				"js-keyboard-nav": keyboardNav,
			},
			cls,
		]}
		data-keyboard-nav-item=".l-card-list__card"
		data-keyboard-nav-mode="grid"
		{...props}
	/>
);