From 01446b3c8306112cd965eeaaa40a0ac573cc374e Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 3 Sep 2020 21:10:58 +0800 Subject: ... --- .../timeline-common/TimelinePageTemplateUI.tsx | 128 ++++++--------------- 1 file changed, 33 insertions(+), 95 deletions(-) (limited to 'Timeline/ClientApp/src/app/views/timeline-common/TimelinePageTemplateUI.tsx') diff --git a/Timeline/ClientApp/src/app/views/timeline-common/TimelinePageTemplateUI.tsx b/Timeline/ClientApp/src/app/views/timeline-common/TimelinePageTemplateUI.tsx index 4296a5ce..c2d4aeaa 100644 --- a/Timeline/ClientApp/src/app/views/timeline-common/TimelinePageTemplateUI.tsx +++ b/Timeline/ClientApp/src/app/views/timeline-common/TimelinePageTemplateUI.tsx @@ -1,11 +1,7 @@ -import React, { CSSProperties } from "react"; -import clsx from "clsx"; +import React from "react"; import { useTranslation } from "react-i18next"; import { fromEvent } from "rxjs"; -import Svg from "react-inlinesvg"; -import { Spinner, Collapse } from "react-bootstrap"; -import arrowsAngleContractIcon from "bootstrap-icons/icons/arrows-angle-contract.svg"; -import arrowsAngleExpandIcon from "bootstrap-icons/icons/arrows-angle-expand.svg"; +import { Spinner } from "react-bootstrap"; import { getAlertHost } from "@/services/alert"; import { useEventEmiiter, UiLogicError } from "@/common"; @@ -21,63 +17,16 @@ import Timeline, { TimelineDeleteCallback, } from "./Timeline"; import TimelinePostEdit, { TimelinePostSendCallback } from "./TimelinePostEdit"; - -type TimelinePostSyncState = "syncing" | "synced" | "offline"; - -const TimelinePostSyncStateBadge: React.FC<{ - state: TimelinePostSyncState; - style?: CSSProperties; - className?: string; -}> = ({ state, style, className }) => { - const { t } = useTranslation(); - - return ( -
- {(() => { - switch (state) { - case "syncing": { - return ( - <> - - - {t("timeline.postSyncState.syncing")} - - - ); - } - case "synced": { - return ( - <> - - - {t("timeline.postSyncState.synced")} - - - ); - } - case "offline": { - return ( - <> - - - {t("timeline.postSyncState.offline")} - - - ); - } - default: - throw new UiLogicError("Unknown sync state."); - } - })()} -
- ); -}; +import { TimelineSyncStatus } from "./SyncStatusBadge"; export interface TimelineCardComponentProps { timeline: TimelineInfo; onManage?: (item: TManageItems | "property") => void; onMember: () => void; className?: string; + collapse: boolean; + syncStatus: TimelineSyncStatus; + toggleCollapse: () => void; } export interface TimelinePageTemplateUIProps { @@ -216,22 +165,13 @@ export default function TimelinePageTemplateUI( }) ); - const syncState: TimelinePostSyncState = postListState.syncing - ? "syncing" - : postListState.type === "synced" - ? "synced" - : "offline"; - timelineBody = ( -
- - -
+ ); if (props.onPost != null) { timelineBody = ( @@ -255,37 +195,35 @@ export default function TimelinePageTemplateUI( ); } + const { CardComponent } = props; + const syncStatus: TimelineSyncStatus = + postListState == null || postListState.syncing + ? "syncing" + : postListState.type === "synced" + ? "synced" + : "offline"; body = ( <> -
- { - const newState = !infoCardCollapse; - setInfoCardCollapse(newState); + { + const newState = !infoCardCollapse; + setInfoCardCollapse(newState); + if (timeline != null) { window.localStorage.setItem( genCardCollapseLocalStorageKey(timeline.uniqueId), newState.toString() ); - }} - className="float-right m-1 info-card-collapse-button text-primary icon-button" - /> - - - -
- + } + }} + /> {timelineBody} ); -- cgit v1.2.3