aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/home/TimelineBoard.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-27 19:21:35 +0800
committercrupest <crupest@outlook.com>2020-10-27 19:21:35 +0800
commitac769e656b122ff569c3f1534701b71e00fed586 (patch)
tree72966645ff1e25139d3995262e1c4349f2c14733 /FrontEnd/src/app/views/home/TimelineBoard.tsx
parent14e5848c23c643cea9b5d709770747d98c3d75e2 (diff)
downloadtimeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.gz
timeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.bz2
timeline-ac769e656b122ff569c3f1534701b71e00fed586.zip
Split front and back end.
Diffstat (limited to 'FrontEnd/src/app/views/home/TimelineBoard.tsx')
-rw-r--r--FrontEnd/src/app/views/home/TimelineBoard.tsx73
1 files changed, 73 insertions, 0 deletions
diff --git a/FrontEnd/src/app/views/home/TimelineBoard.tsx b/FrontEnd/src/app/views/home/TimelineBoard.tsx
new file mode 100644
index 00000000..a3d176e1
--- /dev/null
+++ b/FrontEnd/src/app/views/home/TimelineBoard.tsx
@@ -0,0 +1,73 @@
+import React from "react";
+import clsx from "clsx";
+import { Link } from "react-router-dom";
+import { Trans } from "react-i18next";
+import { Spinner } from "react-bootstrap";
+
+import { TimelineInfo } from "@/services/timeline";
+import TimelineLogo from "../common/TimelineLogo";
+import UserTimelineLogo from "../common/UserTimelineLogo";
+
+export interface TimelineBoardProps {
+ title?: string;
+ timelines: TimelineInfo[] | "offline" | "loading";
+ onReload: () => void;
+ className?: string;
+}
+
+const TimelineBoard: React.FC<TimelineBoardProps> = (props) => {
+ const { title, timelines, className } = props;
+
+ return (
+ <div className={clsx("timeline-board", className)}>
+ {title != null && <h3 className="text-center">{title}</h3>}
+ {(() => {
+ if (timelines === "loading") {
+ return (
+ <div className="d-flex flex-grow-1 justify-content-center align-items-center">
+ <Spinner variant="primary" animation="border" />
+ </div>
+ );
+ } else if (timelines === "offline") {
+ return (
+ <div className="d-flex flex-grow-1 justify-content-center align-items-center">
+ <Trans i18nKey="loadFailReload" parent="div">
+ 0
+ <a
+ href="#"
+ onClick={(e) => {
+ props.onReload();
+ e.preventDefault();
+ }}
+ >
+ 1
+ </a>
+ 2
+ </Trans>
+ </div>
+ );
+ } else {
+ return timelines.map((timeline) => {
+ const { name } = timeline;
+ const isPersonal = name.startsWith("@");
+ const url = isPersonal
+ ? `/users/${timeline.owner.username}`
+ : `/timelines/${name}`;
+ return (
+ <div key={name} className="timeline-board-item">
+ {isPersonal ? (
+ <UserTimelineLogo className="icon" />
+ ) : (
+ <TimelineLogo className="icon" />
+ )}
+ <Link to={url}>{name}</Link>
+ </div>
+ );
+ });
+ }
+ })()}
+ </div>
+ );
+};
+
+export default TimelineBoard;