From fc19008962790e1042b29d1e6afe1a76980223e3 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 20 Feb 2021 22:45:07 +0800 Subject: ... --- .../timeline-common/TimelinePageCardTemplate.tsx | 180 +++++++++------------ .../app/views/timeline-common/timeline-common.sass | 2 +- 2 files changed, 81 insertions(+), 101 deletions(-) (limited to 'FrontEnd/src/app/views/timeline-common') diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx index 13b823bf..6069d54e 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx @@ -1,7 +1,6 @@ import React from "react"; import clsx from "clsx"; import { useTranslation } from "react-i18next"; -import { Dropdown, Button } from "react-bootstrap"; import { getHttpHighlightClient } from "@/http/highlight"; import { getHttpBookmarkClient } from "@/http/bookmark"; @@ -10,28 +9,19 @@ import { useUser } from "@/services/user"; import { pushAlert } from "@/services/alert"; import { timelineVisibilityTooltipTranslationMap } from "@/services/timeline"; +import { useIsSmallScreen } from "@/utilities/mediaQuery"; + import { TimelinePageCardProps } from "./TimelinePageTemplate"; import CollapseButton from "./CollapseButton"; import { TimelineMemberDialog } from "./TimelineMember"; import TimelinePropertyChangeDialog from "./TimelinePropertyChangeDialog"; +import { MenuItems, PopupMenu } from "../common/Menu"; +import FullPage from "../common/FullPage"; export interface TimelineCardTemplateProps extends TimelinePageCardProps { infoArea: React.ReactElement; - manageArea: - | { type: "member" } - | { - type: "manage"; - items: ( - | { - type: "button"; - text: string; - color?: string; - onClick: () => void; - } - | { type: "divider" } - )[]; - }; + manageItems?: MenuItems; dialog: string | "property" | "member" | null; setDialog: (dialog: "property" | "member" | null) => void; } @@ -41,7 +31,7 @@ const TimelinePageCardTemplate: React.FC = ({ collapse, toggleCollapse, infoArea, - manageArea, + manageItems, onReload, className, dialog, @@ -49,100 +39,90 @@ const TimelinePageCardTemplate: React.FC = ({ }) => { const { t } = useTranslation(); + const isSmallScreen = useIsSmallScreen(); + const user = useUser(); - return ( + const content = ( <> -
-
- -
-
- {infoArea} -

{timeline.description}

- - {t(timelineVisibilityTooltipTranslationMap[timeline.visibility])} - -
- { - getHttpHighlightClient() - [timeline.isHighlight ? "delete" : "put"](timeline.name) - .then(onReload, () => { - pushAlert({ - message: timeline.isHighlight - ? "timeline.removeHighlightFail" - : "timeline.addHighlightFail", - type: "danger", - }); - }); - } - : undefined - } - /> - {user != null ? ( - { - getHttpBookmarkClient() - [timeline.isBookmark ? "delete" : "put"](timeline.name) + {infoArea} +

{timeline.description}

+ + {t(timelineVisibilityTooltipTranslationMap[timeline.visibility])} + +
+ { + getHttpHighlightClient() + [timeline.isHighlight ? "delete" : "put"](timeline.name) .then(onReload, () => { pushAlert({ - message: timeline.isBookmark - ? "timeline.removeBookmarkFail" - : "timeline.addBookmarkFail", + message: timeline.isHighlight + ? "timeline.removeHighlightFail" + : "timeline.addHighlightFail", type: "danger", }); }); - }} - /> - ) : null} - {manageArea.type === "manage" ? ( - - - {t("timeline.manage")} - - - {manageArea.items.map((item, index) => { - if (item.type === "divider") { - return ; - } else { - return ( - - {t(item.text)} - - ); - } - })} - - - ) : ( - + } + : undefined + } + /> + {user != null ? ( + + onClick={() => { + getHttpBookmarkClient() + [timeline.isBookmark ? "delete" : "put"](timeline.name) + .then(onReload, () => { + pushAlert({ + message: timeline.isBookmark + ? "timeline.removeBookmarkFail" + : "timeline.addBookmarkFail", + type: "danger", + }); + }); + }} + /> + ) : null} + setDialog("member")} + /> + {manageItems != null ? ( + + + + ) : null} +
+ + ); + + return ( + <> +
+
+
+ {isSmallScreen ? ( + + {content} + + ) : ( +
{content}
+ )}
{(() => { if (dialog === "member") { diff --git a/FrontEnd/src/app/views/timeline-common/timeline-common.sass b/FrontEnd/src/app/views/timeline-common/timeline-common.sass index 31404d8c..c74058c0 100644 --- a/FrontEnd/src/app/views/timeline-common/timeline-common.sass +++ b/FrontEnd/src/app/views/timeline-common/timeline-common.sass @@ -166,7 +166,7 @@ $timeline-line-color-current: #36c2e6 .timeline-template-card position: fixed - z-index: 1 + z-index: 1031 top: 56px right: 0 margin: 0.5em -- cgit v1.2.3