diff --git a/web/src/components/MemoView.tsx b/web/src/components/MemoView.tsx index e59365a2..cae32cc9 100644 --- a/web/src/components/MemoView.tsx +++ b/web/src/components/MemoView.tsx @@ -42,10 +42,12 @@ const MemoView: React.FC = (props: Props) => { const [displayTime, setDisplayTime] = useState(getRelativeTimeString(getTimeStampByDate(memo.displayTime))); const [creator, setCreator] = useState(userStore.getUserByUsername(extractUsernameFromName(memo.creator))); const memoContainerRef = useRef(null); + const [showCompactMode, setShowCompactMode] = useState(false); const referencedMemos = memo.relations.filter((relation) => relation.type === MemoRelation_Type.REFERENCE); const commentAmount = memo.relations.filter((relation) => relation.type === MemoRelation_Type.COMMENT).length; const readonly = memo.creator !== user?.name; + // Initial related data: creator. useEffect(() => { (async () => { const user = await userStore.getOrFetchUserByUsername(extractUsernameFromName(memo.creator)); @@ -53,6 +55,16 @@ const MemoView: React.FC = (props: Props) => { })(); }, []); + // Initial compact mode. + useEffect(() => { + if (!memoContainerRef.current) { + return; + } + if ((memoContainerRef.current as HTMLDivElement).getBoundingClientRect().height > 512) { + setShowCompactMode(true); + } + }, []); + // Update display time string. useEffect(() => { let intervalFlag: any = -1; @@ -151,12 +163,24 @@ const MemoView: React.FC = (props: Props) => { + {showCompactMode && ( +
+ + {t("memo.show-more")} + + +
+ )} diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 902be159..be439e30 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -102,7 +102,8 @@ "comment": { "self": "Comments", "no-comment": "No comment" - } + }, + "show-more": "Show more" }, "resource": { "no-resources": "No resources.", diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsx index 91cd43d2..15421fa5 100644 --- a/web/src/pages/MemoDetail.tsx +++ b/web/src/pages/MemoDetail.tsx @@ -207,7 +207,10 @@ const MemoDetail = () => { -
+
+

+ Comments +

{comments.length === 0 ? (