summaryrefslogtreecommitdiffstats
path: root/src/ui/layouts/Container.tsx
blob: 7ce7ed549c11eeed6560d387fa51a83d143ba07b (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
import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts";

export type Props<Tag extends HTMLTag> = Polymorphic<{
	"as": Tag;
	"pad-inline"?: boolean;
	"pad-block"?: boolean;
	"size"?: "sm";
	"fixed"?: boolean | "150" | "200";
}>;

export const Container = <T extends HTMLTag = "div">({
	as: Tag = "div" as T,
	class: cls,
	"pad-inline": padInline,
	"pad-block": padBlock,
	fixed,
	size,
	...props
}: Props<T>) => (
	<Tag
		class:list={[
			"l-container",
			{
				"l-container--pad-i": padInline,
				"l-container--pad-b": padBlock,
				[`l-container--${size}`]: size,
				[`l-container--fixed${typeof fixed === "boolean" ? "" : `-${fixed}`}`]: fixed,
			},
			cls,
		]}
		{...props}
	/>
);