From 3db441fccf1a933ac8ec9e4f89c19f81efd66052 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 16 Apr 2021 17:03:40 +0800 Subject: ... --- .../src/app/views/home-v2/TimelineListView.tsx | 32 +++++++++++---- FrontEnd/src/app/views/home-v2/home-v2.sass | 11 +++++ FrontEnd/src/app/views/home-v2/index.tsx | 47 +++++++++++++++++++++- 3 files changed, 80 insertions(+), 10 deletions(-) (limited to 'FrontEnd/src/app/views/home-v2') diff --git a/FrontEnd/src/app/views/home-v2/TimelineListView.tsx b/FrontEnd/src/app/views/home-v2/TimelineListView.tsx index 1ba9f765..9c44a0c2 100644 --- a/FrontEnd/src/app/views/home-v2/TimelineListView.tsx +++ b/FrontEnd/src/app/views/home-v2/TimelineListView.tsx @@ -4,14 +4,23 @@ import { convertI18nText, I18nText } from "@/common"; import { HttpTimelineInfo } from "@/http/timeline"; import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; interface TimelineListItemProps { timeline: HttpTimelineInfo; } const TimelineListItem: React.FC = ({ timeline }) => { + const url = React.useMemo( + () => + timeline.name.startsWith("@") + ? `/users/${timeline.owner.username}` + : `/timelines/${timeline.name}`, + [timeline] + ); + return ( -
+
= ({ timeline }) => { fill="#007bff" /> -
{timeline.title}
+
+
{timeline.title}
+
+ {timeline.description} +
+
+ + +
); }; -const TimelineListLoading: React.FC = () => { +const TimelineListArrow: React.FC = () => { return (
@@ -73,11 +90,10 @@ const TimelineListView: React.FC = ({

{convertI18nText(headerText, t)}

- {timelines != null ? ( - timelines.map((t) => ) - ) : ( - - )} + {timelines != null + ? timelines.map((t) => ) + : null} +
); }; diff --git a/FrontEnd/src/app/views/home-v2/home-v2.sass b/FrontEnd/src/app/views/home-v2/home-v2.sass index a3218f08..56049994 100644 --- a/FrontEnd/src/app/views/home-v2/home-v2.sass +++ b/FrontEnd/src/app/views/home-v2/home-v2.sass @@ -2,6 +2,17 @@ display: flex align-items: center +.home-v2-timeline-list-item-timeline + transition: background 0.8s + animation: 0.8s home-v2-timeline-list-item-timeline-enter + &:hover + background: $gray-200 + +@keyframes home-v2-timeline-list-item-timeline-enter + from + transform: translate(-100%,0) + opacity: 0 + .home-v2-timeline-list-item-line width: 80px flex-shrink: 0 diff --git a/FrontEnd/src/app/views/home-v2/index.tsx b/FrontEnd/src/app/views/home-v2/index.tsx index 75c51540..cb3c1428 100644 --- a/FrontEnd/src/app/views/home-v2/index.tsx +++ b/FrontEnd/src/app/views/home-v2/index.tsx @@ -8,6 +8,14 @@ import SearchInput from "../common/SearchInput"; import TimelineListView from "./TimelineListView"; import TimelineCreateDialog from "../home/TimelineCreateDialog"; +import { HttpTimelineInfo } from "@/http/timeline"; +import { getHttpHighlightClient } from "@/http/highlight"; + +const highlightTimelineMessageMap = { + loading: "home.loadingHighlightTimelines", + done: "home.loadedHighlightTimelines", + error: "home.errorHighlightTimelines", +} as const; const HomeV2: React.FC = () => { const history = useHistory(); @@ -20,11 +28,43 @@ const HomeV2: React.FC = () => { const [dialog, setDialog] = React.useState<"create" | null>(null); + const [highlightTimelineState, setHighlightTimelineState] = React.useState< + "loading" | "done" | "error" + >("loading"); + const [highlightTimelines, setHighlightTimelines] = React.useState< + HttpTimelineInfo[] | undefined + >(); + + React.useEffect(() => { + if (highlightTimelineState === "loading") { + let subscribe = true; + void getHttpHighlightClient() + .list() + .then( + (data) => { + if (subscribe) { + setHighlightTimelineState("done"); + setHighlightTimelines(data); + } + }, + () => { + if (subscribe) { + setHighlightTimelineState("error"); + setHighlightTimelines(undefined); + } + } + ); + return () => { + subscribe = false; + }; + } + }, [highlightTimelineState]); + return ( <> - + { /> - + {dialog === "create" && ( setDialog(null)} /> -- cgit v1.2.3