aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-22 00:27:33 +0800
committercrupest <crupest@outlook.com>2020-12-22 00:27:33 +0800
commita337ce43ae91c0c9a1c359dbb91faf75f1375505 (patch)
tree8b71ace9f10c8ce9a13363cdb3de7a29696fc5e0 /FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx
parentd960fdcfb79caf257fed6b68cc169a785003d965 (diff)
downloadtimeline-a337ce43ae91c0c9a1c359dbb91faf75f1375505.tar.gz
timeline-a337ce43ae91c0c9a1c359dbb91faf75f1375505.tar.bz2
timeline-a337ce43ae91c0c9a1c359dbb91faf75f1375505.zip
...
Diffstat (limited to 'FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx')
-rw-r--r--FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx128
1 files changed, 54 insertions, 74 deletions
diff --git a/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx b/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx
index 8f967a34..f4dbb67d 100644
--- a/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx
+++ b/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx
@@ -1,93 +1,73 @@
import React from "react";
-import { useTranslation } from "react-i18next";
-import { Dropdown, Button } from "react-bootstrap";
-import Svg from "react-inlinesvg";
-import bookmarkIcon from "bootstrap-icons/icons/bookmark.svg";
import { useAvatar } from "@/services/user";
-import { timelineVisibilityTooltipTranslationMap } from "@/services/timeline";
import BlobImage from "../common/BlobImage";
+import TimelineCardTemplate, {
+ TimelineCardTemplateProps,
+} from "../timeline-common/TimelineCardTemplate";
import { TimelineCardComponentProps } from "../timeline-common/TimelinePageTemplateUI";
-import InfoCardTemplate from "../timeline-common/InfoCardTemplate";
export type OrdinaryTimelineManageItem = "delete";
export type TimelineInfoCardProps = TimelineCardComponentProps<OrdinaryTimelineManageItem>;
const TimelineInfoCard: React.FC<TimelineInfoCardProps> = (props) => {
- const {
- timeline,
- collapse,
- onMember,
- onBookmark,
- onManage,
- syncStatus,
- toggleCollapse,
- } = props;
-
- const { t } = useTranslation();
+ const { onMember, onManage, ...otherProps } = props;
+ const { timeline } = props;
const avatar = useAvatar(timeline?.owner?.username);
return (
- <InfoCardTemplate
- className={props.className}
- syncStatus={syncStatus}
- collapse={collapse}
- toggleCollapse={toggleCollapse}
- >
- <h3 className="text-primary d-inline-block align-middle">
- {timeline.title}
- <small className="ml-3 text-secondary">{timeline.name}</small>
- </h3>
- <div className="align-middle">
- <BlobImage blob={avatar} className="avatar small rounded-circle mr-3" />
- {timeline.owner.nickname}
- <small className="ml-3 text-secondary">
- @{timeline.owner.username}
- </small>
- </div>
- <p className="mb-0">{timeline.description}</p>
- <small className="mt-1 d-block">
- {t(timelineVisibilityTooltipTranslationMap[timeline.visibility])}
- </small>
- <div className="text-right mt-2">
- {onBookmark != null ? (
- <Svg
- src={bookmarkIcon}
- className="icon-button text-yellow mr-3"
- onClick={onBookmark}
- />
- ) : null}
- {onManage != null ? (
- <Dropdown className="d-inline-block">
- <Dropdown.Toggle variant="outline-primary">
- {t("timeline.manage")}
- </Dropdown.Toggle>
- <Dropdown.Menu>
- <Dropdown.Item onClick={() => onManage("property")}>
- {t("timeline.manageItem.property")}
- </Dropdown.Item>
- <Dropdown.Item onClick={onMember}>
- {t("timeline.manageItem.member")}
- </Dropdown.Item>
- <Dropdown.Divider />
- <Dropdown.Item
- className="text-danger"
- onClick={() => onManage("delete")}
- >
- {t("timeline.manageItem.delete")}
- </Dropdown.Item>
- </Dropdown.Menu>
- </Dropdown>
- ) : (
- <Button variant="outline-primary" onClick={onMember}>
- {t("timeline.memberButton")}
- </Button>
- )}
- </div>
- </InfoCardTemplate>
+ <TimelineCardTemplate
+ infoArea={
+ <>
+ <h3 className="text-primary d-inline-block align-middle">
+ {timeline.title}
+ <small className="ml-3 text-secondary">{timeline.name}</small>
+ </h3>
+ <div className="align-middle">
+ <BlobImage
+ blob={avatar}
+ className="avatar small rounded-circle mr-3"
+ />
+ {timeline.owner.nickname}
+ <small className="ml-3 text-secondary">
+ @{timeline.owner.username}
+ </small>
+ </div>
+ </>
+ }
+ manageArea={((): TimelineCardTemplateProps["manageArea"] => {
+ if (onManage == null) {
+ return { type: "member", onMember };
+ } else {
+ return {
+ type: "manage",
+ items: [
+ {
+ type: "button",
+ text: "timeline.manageItem.property",
+ onClick: () => onManage("property"),
+ },
+ {
+ type: "button",
+ onClick: onMember,
+ text: "timeline.manageItem.member",
+ },
+ { type: "divider" },
+ {
+ type: "button",
+ onClick: () => onManage("delete"),
+ color: "danger",
+ text: "timeline.manageItem.delete",
+ },
+ ],
+ };
+ }
+ })()}
+ {...otherProps}
+ />
);
};