From a7d7a50bf6c6d489c1d763fb8ebb6b44eb0b4db7 Mon Sep 17 00:00:00 2001 From: RoccoSmit Date: Sat, 23 Nov 2024 17:12:17 +1100 Subject: [PATCH] Added show less action and language files --- web/src/components/MemoContent/index.tsx | 22 +++++++++++++++------- web/src/locales/en.json | 1 + web/src/locales/es.json | 1 + web/src/locales/fr.json | 1 + web/src/locales/hu.json | 1 + web/src/locales/id.json | 1 + web/src/locales/ja.json | 1 + web/src/locales/ka-GE.json | 1 + web/src/locales/ko.json | 1 + web/src/locales/mr.json | 1 + web/src/locales/pl.json | 1 + web/src/locales/pt-BR.json | 1 + web/src/locales/pt-PT.json | 1 + web/src/locales/ru.json | 1 + web/src/locales/sl.json | 1 + web/src/locales/th.json | 1 + web/src/locales/tr.json | 1 + web/src/locales/uk.json | 1 + web/src/locales/vi.json | 1 + web/src/locales/zh-Hans.json | 1 + web/src/locales/zh-Hant.json | 1 + 21 files changed, 35 insertions(+), 7 deletions(-) diff --git a/web/src/components/MemoContent/index.tsx b/web/src/components/MemoContent/index.tsx index 1310584c84959..507bd71924a89 100644 --- a/web/src/components/MemoContent/index.tsx +++ b/web/src/components/MemoContent/index.tsx @@ -26,13 +26,15 @@ interface Props { onDoubleClick?: (e: React.MouseEvent) => void; } +type compactModes = "more" | "less" | "none"; + const MemoContent: React.FC = (props: Props) => { const { className, contentClassName, nodes, memoName, embeddedMemos, onClick, onDoubleClick } = props; const t = useTranslate(); const currentUser = useCurrentUser(); const memoStore = useMemoStore(); const memoContentContainerRef = useRef(null); - const [showCompactMode, setShowCompactMode] = useState(false); + const [showCompactMode, setShowCompactMode] = useState("none"); const memo = memoName ? memoStore.getMemoByName(memoName) : null; const allowEdit = !props.readonly && memo && (currentUser?.name === memo.creator || isSuperUser(currentUser)); @@ -46,7 +48,7 @@ const MemoContent: React.FC = (props: Props) => { } if ((memoContentContainerRef.current as HTMLDivElement).getBoundingClientRect().height > MAX_DISPLAY_HEIGHT) { - setShowCompactMode(true); + setShowCompactMode("more"); } }, []); @@ -64,6 +66,10 @@ const MemoContent: React.FC = (props: Props) => { let prevNode: Node | null = null; let skipNextLineBreakFlag = false; + const compactStates = { + more: { text: t("memo.show-more"), nextState: "less" }, + less: { text: t("memo.show-less"), nextState: "more" }, + }; return ( = (props: Props) => { ref={memoContentContainerRef} className={clsx( "relative w-full max-w-full word-break text-base leading-snug space-y-2 whitespace-pre-wrap", - showCompactMode && "line-clamp-6 max-h-60", + showCompactMode == "more" && "line-clamp-6 max-h-60", contentClassName, )} onClick={handleMemoContentClick} @@ -95,17 +101,19 @@ const MemoContent: React.FC = (props: Props) => { skipNextLineBreakFlag = true; return ; })} - {showCompactMode && ( + {showCompactMode == "more" && (
)} - {showCompactMode && ( + {showCompactMode != "none" && (
setShowCompactMode(false)} + onClick={() => { + setShowCompactMode(compactStates[showCompactMode].nextState as compactModes); + }} > - {t("memo.show-more")} + {compactStates[showCompactMode].text}
)} diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 7876024b657cd..33c4e08fd1d48 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -109,6 +109,7 @@ "no-archived-memos": "No archived memos.", "search-placeholder": "Search memos", "show-more": "Show more", + "show-less": "Show less", "view-detail": "View Detail", "visibility": { "disabled": "Public memos are disabled", diff --git a/web/src/locales/es.json b/web/src/locales/es.json index 62856ecc26129..9b27e96e56ee3 100644 --- a/web/src/locales/es.json +++ b/web/src/locales/es.json @@ -99,6 +99,7 @@ "no-archived-memos": "No hay memos archivados.", "search-placeholder": "Buscar memos", "show-more": "Mostrar más", + "show-less": "Mostrar menos", "view-detail": "Ver detalles", "visibility": { "disabled": "Los memos públicos están deshabilitados", diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index 85212d3ba2858..cda7ea7861f04 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -111,6 +111,7 @@ "no-archived-memos": "Pas de memos archivés.", "search-placeholder": "Recherche de memos", "show-more": "Afficher plus", + "show-less": "Afficher moins", "to-do": "À faire", "view-detail": "Voir le détail", "visibility": { diff --git a/web/src/locales/hu.json b/web/src/locales/hu.json index 039d6bb03f6b3..e0bd87803dea4 100644 --- a/web/src/locales/hu.json +++ b/web/src/locales/hu.json @@ -107,6 +107,7 @@ "no-archived-memos": "Nincsenek archivált jegyzetek.", "search-placeholder": "Jegyzetek keresése", "show-more": "Több mutatása", + "show-less": "Mutass kevesebbet", "view-detail": "Részletek", "visibility": { "disabled": "A nyilvános jegyzetek le vannak tiltva", diff --git a/web/src/locales/id.json b/web/src/locales/id.json index 4062ac1405514..34eb2f4a0eb66 100644 --- a/web/src/locales/id.json +++ b/web/src/locales/id.json @@ -109,6 +109,7 @@ "no-archived-memos": "Tidak ada memo yang diarsipkan.", "search-placeholder": "Cari memo", "show-more": "Tampilkan lebih banyak", + "show-less": "Tampilkan lebih sedikit", "view-detail": "Lihat Detail", "visibility": { "disabled": "Memo publik dinonaktifkan", diff --git a/web/src/locales/ja.json b/web/src/locales/ja.json index 703c2eafa8071..f4f2f7c60e165 100644 --- a/web/src/locales/ja.json +++ b/web/src/locales/ja.json @@ -111,6 +111,7 @@ "no-archived-memos": "アーカイブされたメモはありません。", "search-placeholder": "メモを検索", "show-more": "続きを見る", + "show-less": "表示を少なくする", "to-do": "To-do", "view-detail": "詳細を見る", "visibility": { diff --git a/web/src/locales/ka-GE.json b/web/src/locales/ka-GE.json index f41172a3350de..dacbd0fd83aac 100644 --- a/web/src/locales/ka-GE.json +++ b/web/src/locales/ka-GE.json @@ -109,6 +109,7 @@ "no-archived-memos": "დაარქივებული მემოები არ არის.", "search-placeholder": "მემოების ძიება", "show-more": "მეტის ჩვენება", + "show-less": "ნაკლების ჩვენება", "view-detail": "დეტალების ნახვა", "visibility": { "disabled": "საჯარო მემოები გამორთულია", diff --git a/web/src/locales/ko.json b/web/src/locales/ko.json index 89e8fc0b7e34a..e0189bdbd962b 100644 --- a/web/src/locales/ko.json +++ b/web/src/locales/ko.json @@ -96,6 +96,7 @@ "no-archived-memos": "보관처리된 메모가 없습니다.", "search-placeholder": "메모 검색하기", "show-more": "더보기", + "show-less": "간략히 보기", "view-detail": "자세히 보기", "visibility": { "disabled": "공개 메모는 비활성화됨", diff --git a/web/src/locales/mr.json b/web/src/locales/mr.json index aba93762573a0..add4b9ccf660d 100644 --- a/web/src/locales/mr.json +++ b/web/src/locales/mr.json @@ -109,6 +109,7 @@ "no-archived-memos": "कोणतेही संग्रहित मेमो नाहीत.", "search-placeholder": "मेमोज शोधा", "show-more": "अधिक दाखवा", + "show-less": "कमी दाखवा", "view-detail": "तपशील दाखवा", "visibility": { "disabled": "सार्वजनिक मेमो अक्षम केले आहेत", diff --git a/web/src/locales/pl.json b/web/src/locales/pl.json index 25a3572725d40..6d450209663dc 100644 --- a/web/src/locales/pl.json +++ b/web/src/locales/pl.json @@ -108,6 +108,7 @@ "no-archived-memos": "Brak zarchiwizowanych notatek.", "search-placeholder": "Szukaj notatek", "show-more": "Pokaż więcej", + "show-less": "Pokaż mniej", "view-detail": "Zobacz szczegóły", "visibility": { "disabled": "Publiczne notatki są wyłączone", diff --git a/web/src/locales/pt-BR.json b/web/src/locales/pt-BR.json index 6d0b642ceee17..5d93a56b8b615 100644 --- a/web/src/locales/pt-BR.json +++ b/web/src/locales/pt-BR.json @@ -111,6 +111,7 @@ "no-archived-memos": "Nenhum memo arquivado.", "search-placeholder": "Pesquisar memos", "show-more": "Mostrar mais", + "show-less": "Mostrar menos", "to-do": "Tarefas", "view-detail": "Ver detalhes", "visibility": { diff --git a/web/src/locales/pt-PT.json b/web/src/locales/pt-PT.json index 5f23d6d5a5464..cc687418555fc 100644 --- a/web/src/locales/pt-PT.json +++ b/web/src/locales/pt-PT.json @@ -109,6 +109,7 @@ "no-archived-memos": "Não existem memos arquivados.", "search-placeholder": "Pesquisar memos", "show-more": "Mostrar mais", + "show-less": "Mostrar menos", "view-detail": "Ver detalhes", "visibility": { "disabled": "Memos públicos estão desativados", diff --git a/web/src/locales/ru.json b/web/src/locales/ru.json index bcc9c92b7a936..f9a3e8252db48 100644 --- a/web/src/locales/ru.json +++ b/web/src/locales/ru.json @@ -106,6 +106,7 @@ "no-archived-memos": "Нет заархивированных записей.", "search-placeholder": "Поиск записей", "show-more": "Подробнее", + "show-less": "Показать меньше", "view-detail": "Подробно", "visibility": { "disabled": "Публичные записи отключены", diff --git a/web/src/locales/sl.json b/web/src/locales/sl.json index 6721579932ad9..866b835f7beea 100644 --- a/web/src/locales/sl.json +++ b/web/src/locales/sl.json @@ -109,6 +109,7 @@ "no-archived-memos": "Ni arhiviranih beležk.", "search-placeholder": "Poišči beležke", "show-more": "Prikaži več", + "show-less": "Prikaži manj", "view-detail": "Poglej podrobnosti", "visibility": { "disabled": "Javne beležke so onemogočene", diff --git a/web/src/locales/th.json b/web/src/locales/th.json index c5a71ebad9317..0c641efcb8ac5 100644 --- a/web/src/locales/th.json +++ b/web/src/locales/th.json @@ -111,6 +111,7 @@ "no-archived-memos": "ไม่มีบันทึกช่วยจำที่ถูกเก็บถาวร", "search-placeholder": "ค้นหาบันทึกช่วยจำ", "show-more": "แสดงเพิ่มเติม", + "show-less": "แสดงน้อยลง", "to-do": "สิ่งที่ต้องทำ", "view-detail": "ดูรายละเอียด", "visibility": { diff --git a/web/src/locales/tr.json b/web/src/locales/tr.json index aeb2386ec6670..fd8bfec0e8c58 100644 --- a/web/src/locales/tr.json +++ b/web/src/locales/tr.json @@ -111,6 +111,7 @@ "no-archived-memos": "Arşivlenmiş not yok.", "search-placeholder": "Notları ara", "show-more": "Daha fazlasını göster", + "show-less": "Daha az göster", "to-do": "Yapılacaklar", "view-detail": "Detayları görüntüle", "visibility": { diff --git a/web/src/locales/uk.json b/web/src/locales/uk.json index b2d9280e2f83b..37c5f795f313d 100644 --- a/web/src/locales/uk.json +++ b/web/src/locales/uk.json @@ -109,6 +109,7 @@ "no-archived-memos": "Немає архівованих нотаток.", "search-placeholder": "Пошук нотаток", "show-more": "Показати більше", + "show-less": "Показувати менше", "view-detail": "Переглянути деталі", "visibility": { "disabled": "Публічні нотатки вимкнені", diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index dc51af1284af6..7822c23b1f9f5 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -109,6 +109,7 @@ "no-archived-memos": "Không có ghi chú nào được lưu trữ.", "search-placeholder": "Tìm kiếm ghi chú", "show-more": "Hiển thị thêm", + "show-less": "Hiển thị ít hơn", "view-detail": "Xem chi tiết", "visibility": { "disabled": "Ghi chú công khai đã bị vô hiệu hóa", diff --git a/web/src/locales/zh-Hans.json b/web/src/locales/zh-Hans.json index 506021880b5f6..97fedc895cfad 100644 --- a/web/src/locales/zh-Hans.json +++ b/web/src/locales/zh-Hans.json @@ -109,6 +109,7 @@ "no-archived-memos": "没有已归档备忘录。", "search-placeholder": "搜索备忘录", "show-more": "查看更多", + "show-less": "显示较少", "view-detail": "查看详情", "visibility": { "disabled": "已禁用公开备忘录", diff --git a/web/src/locales/zh-Hant.json b/web/src/locales/zh-Hant.json index 4731b3329ff84..697ce8cd9ab50 100644 --- a/web/src/locales/zh-Hant.json +++ b/web/src/locales/zh-Hant.json @@ -111,6 +111,7 @@ "no-archived-memos": "無封存的 Memos", "search-placeholder": "搜尋 Memos", "show-more": "查看更多", + "show-less": "顯示較少", "to-do": "待辦", "view-detail": "查看詳情", "visibility": {