aboutsummaryrefslogtreecommitdiff
path: root/apps/website/src/components/base/Slider.astro
blob: f40b747f78e4d0d36bb694514a364c7bb9e657fe (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<'div'> {
	dir?: string;
	wrapperClass?: string;
}

const {
	dir = "left",
	wrapperClass = ""
} = Astro.props;
---

<div class={
	`w-full bg-blue-100 flex flex-row gap-2.5 overflow-hidden slider
	${dir === "right" ? "reverse" : ""}
	${wrapperClass}`}>
	<slot />
</div>

<!-- might be cheating a bit using global styles here but at least it lets you use slots -->
<style is:global>
	.slider > * {
		animation: 5s linear infinite slide;
	}
	.slider.reverse > * {
		animation-direction: reverse;
	}
	@keyframes slide {
		from {
			transform: translateX(0);
		}
		to {
			transform: translateX(calc(-100% - 10px));
		}
	}
</style>