From b6beb5f02e8c291f2b5f2bc7d0c15d0955336c32 Mon Sep 17 00:00:00 2001
From: Jan Tuomi <jans.tuomi@gmail.com>
Date: Fri, 2 Jul 2021 11:19:25 +0300
Subject: Implement research papers

---
 frontend/components/Marquees/Marquees.tsx | 35 +++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 frontend/components/Marquees/Marquees.tsx

(limited to 'frontend/components/Marquees/Marquees.tsx')

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;
-- 
cgit v1.3

