From f0f1984405db795d5a60bd03d05bec524dc12db3 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Mon, 31 Jul 2023 17:15:53 +0800
Subject: ...

---
 FrontEnd/src/pages/timeline/TimelineCard.tsx | 94 ++++++++++++++--------------
 1 file changed, 46 insertions(+), 48 deletions(-)

(limited to 'FrontEnd/src/pages/timeline/TimelineCard.tsx')

diff --git a/FrontEnd/src/pages/timeline/TimelineCard.tsx b/FrontEnd/src/pages/timeline/TimelineCard.tsx
index bcdfa4c2..cdc8a5a7 100644
--- a/FrontEnd/src/pages/timeline/TimelineCard.tsx
+++ b/FrontEnd/src/pages/timeline/TimelineCard.tsx
@@ -1,15 +1,13 @@
 import { useState } from "react";
-import classnames from "classnames";
 import { HubConnectionState } from "@microsoft/signalr";
 
-import { useIsSmallScreen } from "@/utilities/hooks";
-import { timelineVisibilityTooltipTranslationMap } from "@/services/timeline";
 import { useUser } from "@/services/user";
 import { pushAlert } from "@/services/alert";
+
 import { HttpTimelineInfo } from "@/http/timeline";
 import { getHttpBookmarkClient } from "@/http/bookmark";
 
-import { useC } from "@/views/common/common";
+import { useMobile } from "@/views/common/common";
 import { useDialog } from "@/views/common/dialog";
 import UserAvatar from "@/views/common/user/UserAvatar";
 import PopupMenu from "@/views/common/menu/PopupMenu";
@@ -35,17 +33,18 @@ export default function TimelineCard(props: TimelinePageCardProps) {
 
   const user = useUser();
 
-  const c = useC();
-
   const [collapse, setCollapse] = useState(true);
   const toggleCollapse = (): void => {
     setCollapse((o) => !o);
   };
 
-  const isSmallScreen = useIsSmallScreen();
+  const isMobile = useMobile();
 
-  const { createDialogSwitch, dialog, dialogPropsMap, switchDialog } =
-    useDialog(["member", "property", "delete"]);
+  const { createDialogSwitch, dialogPropsMap } = useDialog([
+    "member",
+    "property",
+    "delete",
+  ]);
 
   const content = (
     <div className="cru-primary">
@@ -53,25 +52,24 @@ export default function TimelineCard(props: TimelinePageCardProps) {
         {timeline.title}
         <small className="timeline-card-title-name">{timeline.nameV2}</small>
       </h3>
-      <div>
+      <div className="timeline-card-user">
         <UserAvatar
           username={timeline.owner.username}
-          className="cru-avatar small cru-round me-3"
+          className="timeline-card-user-avatar"
         />
-        {timeline.owner.nickname}
-        <small className="ms-3 cru-color-secondary">
+        <span className="timeline-card-user-nickname">
+          {timeline.owner.nickname}
+        </span>
+        <small className="timeline-card-user-username">
           @{timeline.owner.username}
         </small>
       </div>
-      <p className="mb-0">{timeline.description}</p>
-      <small className="mt-1 d-block">
-        {c(timelineVisibilityTooltipTranslationMap[timeline.visibility])}
-      </small>
-      <div className="mt-2 cru-text-end">
-        {user != null ? (
+      <p className="timeline-card-description">{timeline.description}</p>
+      <div className="timeline-card-buttons">
+        {user && (
           <IconButton
             icon={timeline.isBookmark ? "bookmark-fill" : "bookmark"}
-            className="me-3"
+            className="timeline-card-button"
             onClick={() => {
               getHttpBookmarkClient()
                 [timeline.isBookmark ? "delete" : "post"](
@@ -89,13 +87,13 @@ export default function TimelineCard(props: TimelinePageCardProps) {
                 });
             }}
           />
-        ) : null}
+        )}
         <IconButton
           icon="people"
-          className="me-3"
+          className="timeline-card-button"
           onClick={createDialogSwitch("member")}
         />
-        {timeline.manageable ? (
+        {timeline.manageable && (
           <PopupMenu
             items={[
               {
@@ -113,37 +111,37 @@ export default function TimelineCard(props: TimelinePageCardProps) {
             ]}
             containerClassName="d-inline"
           >
-            <IconButton icon="three-dots-vertical" />
+            <IconButton
+              className="timeline-card-button"
+              icon="three-dots-vertical"
+            />
           </PopupMenu>
-        ) : null}
+        )}
       </div>
     </div>
   );
 
   return (
-    <>
-      <Card className="timeline-card">
-        <div
-          className={classnames(
-            "cru-float-right d-flex align-items-center",
-            !collapse && "ms-3",
-          )}
+    <Card
+      className={`timeline-card timeline-card-${
+        collapse ? "collapse" : "expand"
+      }`}
+    >
+      <div className="timeline-card-top-right-area">
+        <ConnectionStatusBadge status={connectionStatus} />
+        <CollapseButton collapse={collapse} onClick={toggleCollapse} />
+      </div>
+      {isMobile ? (
+        <FullPageDialog
+          onBack={toggleCollapse}
+          show={!collapse}
+          contentContainerClassName="p-2"
         >
-          <ConnectionStatusBadge status={connectionStatus} className="me-2" />
-          <CollapseButton collapse={collapse} onClick={toggleCollapse} />
-        </div>
-        {isSmallScreen ? (
-          <FullPageDialog
-            onBack={toggleCollapse}
-            show={!collapse}
-            contentContainerClassName="p-2"
-          >
-            {content}
-          </FullPageDialog>
-        ) : (
-          <div style={{ display: collapse ? "none" : "inline" }}>{content}</div>
-        )}
-      </Card>
+          {content}
+        </FullPageDialog>
+      ) : (
+        <div style={{ display: collapse ? "none" : "block" }}>{content}</div>
+      )}
       <TimelineMemberDialog
         timeline={timeline}
         onChange={onReload}
@@ -155,6 +153,6 @@ export default function TimelineCard(props: TimelinePageCardProps) {
         {...dialogPropsMap["property"]}
       />
       <TimelineDeleteDialog timeline={timeline} {...dialogPropsMap["delete"]} />
-    </>
+    </Card>
   );
 }
-- 
cgit v1.2.3

