From 5248e3ff3f1fd03a519476a7f9ebd3792faa1e43 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 4 Apr 2021 23:50:25 +0800 Subject: ... --- .../src/app/views/timeline-common/Timeline.tsx | 38 +++++++++------------- .../views/timeline-common/TimelinePageTemplate.tsx | 1 - .../timeline-common/TimelinePagedPostListView.tsx | 21 +++++++----- .../views/timeline-common/TimelinePostListView.tsx | 17 ++++++---- .../app/views/timeline-common/TimelinePostView.tsx | 5 +-- .../app/views/timeline-common/timeline-common.sass | 17 ++++++++++ 6 files changed, 58 insertions(+), 41 deletions(-) (limited to 'FrontEnd/src') diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx index f7f7dcfc..60fbc45c 100644 --- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx +++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx @@ -13,7 +13,6 @@ import TimelineTop from "./TimelineTop"; export interface TimelineProps { className?: string; style?: React.CSSProperties; - top?: string | number; timelineName: string; reloadKey: number; onReload: () => void; @@ -21,15 +20,7 @@ export interface TimelineProps { } const Timeline: React.FC = (props) => { - const { - timelineName, - className, - style, - top, - reloadKey, - onReload, - onLoad, - } = props; + const { timelineName, className, style, reloadKey, onReload, onLoad } = props; const [state, setState] = React.useState< "loading" | "loaded" | "offline" | "notexist" | "forbid" | "error" @@ -81,14 +72,16 @@ const Timeline: React.FC = (props) => { switch (state) { case "loading": return ( - + <> + + ); case "offline": return ( @@ -116,11 +109,10 @@ const Timeline: React.FC = (props) => { ); default: return ( - + <> + + + ); } }; diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 1c8873f9..5cde014b 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -149,7 +149,6 @@ const TimelinePageTemplate: React.FC = (props) => { }} > void; } @@ -15,16 +16,21 @@ export interface TimelinePagedPostListViewProps { const TimelinePagedPostListView: React.FC = ( props ) => { - const { className, style, top, posts, onReload } = props; + const { className, style, posts, onReload } = props; const [lastViewCount, setLastViewCount] = React.useState(10); const viewingPosts = React.useMemo(() => { - if (lastViewCount >= posts.length) { - return posts; - } else { - return posts.slice(-lastViewCount, -1); + const p: TimelinePostListViewProps["posts"] = + lastViewCount >= posts.length + ? posts.slice() + : posts.slice(-lastViewCount); + + for (let i = 0; i < p.length; i++) { + p[p.length - i - 1].enterDelay = (i % 10) * 0.4; } + + return p; }, [posts, lastViewCount]); React.useEffect(() => { @@ -43,7 +49,6 @@ const TimelinePagedPostListView: React.FC = ( diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePostListView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePostListView.tsx index fe12b806..4cffe593 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePostListView.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePostListView.tsx @@ -5,7 +5,6 @@ import { HttpTimelinePostInfo } from "@/http/timeline"; import TimelinePostView from "./TimelinePostView"; import TimelineDateLabel from "./TimelineDateLabel"; -import TimelineTop from "./TimelineTop"; function dateEqual(left: Date, right: Date): boolean { return ( @@ -18,20 +17,22 @@ function dateEqual(left: Date, right: Date): boolean { export interface TimelinePostListViewProps { className?: string; style?: React.CSSProperties; - top?: string | number; - posts: HttpTimelinePostInfo[]; + posts: (HttpTimelinePostInfo & { enterDelay?: number })[]; onReload: () => void; } const TimelinePostListView: React.FC = (props) => { - const { className, style, top, posts, onReload } = props; + const { className, style, posts, onReload } = props; const groupedPosts = React.useMemo< - { date: Date; posts: (HttpTimelinePostInfo & { index: number })[] }[] + { + date: Date; + posts: (HttpTimelinePostInfo & { index: number; enterDelay?: number })[]; + }[] >(() => { const result: { date: Date; - posts: (HttpTimelinePostInfo & { index: number })[]; + posts: (HttpTimelinePostInfo & { index: number; enterDelay?: number })[]; }[] = []; let index = 0; for (const post of posts) { @@ -53,7 +54,6 @@ const TimelinePostListView: React.FC = (props) => { return (
- {top && } {groupedPosts.map((group) => { return ( @@ -65,6 +65,9 @@ const TimelinePostListView: React.FC = (props) => { post={post} current={posts.length - 1 === post.index} onDeleted={onReload} + cardStyle={{ + animationDelay: `${post.enterDelay ?? 0}s`, + }} /> ); })} diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePostView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePostView.tsx index 3d075f0e..4cafdaa0 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePostView.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePostView.tsx @@ -16,11 +16,12 @@ export interface TimelinePostViewProps { current?: boolean; className?: string; style?: React.CSSProperties; + cardStyle?: React.CSSProperties; onDeleted?: () => void; } const TimelinePostView: React.FC = (props) => { - const { post, className, style, onDeleted } = props; + const { post, className, style, cardStyle, onDeleted } = props; const current = props.current === true; const [ @@ -36,7 +37,7 @@ const TimelinePostView: React.FC = (props) => { style={style} > -
+
{post.editable ? (