aboutsummaryrefslogtreecommitdiff
path: root/apps/website/src/components/base/Section.astro
blob: 66ad00f40d76b9d96e7c2fdacbd8f23c428d602b (plain)
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
---
import type { HTMLAttributes } from "astro/types";

interface Props extends HTMLAttributes<"section"> {
	maxWidth?: "none" | String;
	colReverse?: boolean;
	wrapperClass?: string;
}

const {
	maxWidth = "1080px",
	colReverse = true,
	wrapperClass = "",
	...props
} = Astro.props;

const twoColumn = Astro.slots.has("left") || Astro.slots.has("right");

const className = `max-w-[${maxWidth}] flex-grow px-5 md:p-0 flex gap-4`
	+ (twoColumn ? ` justify-between md:justify-evenly lg:justify-between ${colReverse ? "flex-col-reverse" : "flex-col"} md:flex-row md:items-center md:flex-row` : "")
	+ (props.class ? ` ${props.class}` : "");
---

<section class={`w-full flex justify-center${wrapperClass ? ` ${wrapperClass}` : ""}`}>
	<div class={className} {...props}>
		{twoColumn ? (
			<div class="flex flex-col items-start text-left relative">
				<slot name="left"></slot>
			</div>

			<div class="flex flex-col items-start text-start relative">
				<slot name="right"></slot>
			</div>
		) : (
			<slot></slot>
		)}
	</div>
</section>