aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/components/Marquees/Marquees.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/components/Marquees/Marquees.tsx')
-rw-r--r--frontend/components/Marquees/Marquees.tsx35
1 files changed, 35 insertions, 0 deletions
diff --git a/frontend/components/Marquees/Marquees.tsx b/frontend/components/Marquees/Marquees.tsx
new file mode 100644
index 0000000..04747fb
--- /dev/null
+++ b/frontend/components/Marquees/Marquees.tsx
@@ -0,0 +1,35 @@
+import React, { ReactElement } from "react";
+import styles from "./Marquee.module.css";
+import Marquee from "./Marquee";
+
+export interface MarqueeLink {
+ title: string;
+ url: string;
+}
+
+interface Props {
+ links: MarqueeLink[]
+}
+
+const getRandomDelayBetween = (start: number, end: number) => `${Math.random() * (end - start) + start}s`;
+const getTopFromIndex = (index: number, n: number) => `calc((100% - 50px) * (${index} / ${n - 1}))`;
+const getRandomAnimationName = () => Math.random() > 0.5 ? "right" : "left";
+
+const Marquees = ({ links }: Props): ReactElement => {
+ return (
+ <div className={styles.marqueeContainer}>
+ { links.map((link, idx) => (
+ <Marquee
+ key={idx}
+ url={link.url}
+ text={link.title}
+ delayShorthand={getRandomDelayBetween(0, 9)}
+ topShorthand={getTopFromIndex(idx, links.length)}
+ direction={getRandomAnimationName()}
+ />
+ ))}
+ </div>
+ );
+};
+
+export default Marquees;