From 46a91694544a8a76d8f67624485a54162b9209aa Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 27 Oct 2023 08:15:36 +0200 Subject: [PATCH 1/7] refactor(home): revert modal design for comments --- src/app.tsx | 7 +++--- src/components/views/home/home.tsx | 36 +++++++++++------------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index f19b1ac1..f3876f67 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -14,11 +14,10 @@ function App() { }, [theme]); return ( -
+
- }> - } /> - + } /> + } />
); diff --git a/src/components/views/home/home.tsx b/src/components/views/home/home.tsx index 6be03c7c..affe1042 100644 --- a/src/components/views/home/home.tsx +++ b/src/components/views/home/home.tsx @@ -1,5 +1,5 @@ import { FC, useEffect, useRef } from 'react'; -import { useLocation, useParams } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso'; import { useFeed } from '@plebbit/plebbit-react-hooks'; import useDefaultSubplebbits from '../../../hooks/use-default-subplebbits'; @@ -7,7 +7,6 @@ import styles from './home.module.css'; import TopBar from '../../topbar/topbar'; import Header from '../../header'; import Post from '../../post'; -import Comments from '../comments/comments'; const lastVirtuosoStates: { [key: string]: StateSnapshot } = {}; @@ -16,11 +15,8 @@ const NoPosts = () => 'no posts'; const Home: FC = () => { const subplebbitAddresses = useDefaultSubplebbits(); const sortType = useParams<{ sortType: string }>().sortType || 'hot'; - const { subplebbitAddress, commentCid } = useParams(); const { feed, hasMore, loadMore } = useFeed({ subplebbitAddresses, sortType }); const loadingStateString = 'loading...'; - const { pathname } = useLocation(); - const isCommentsModalOpen = pathname === `/p/${subplebbitAddress}/c/${commentCid}`; useEffect(() => { document.title = `seedit`; @@ -55,24 +51,18 @@ const Home: FC = () => {
- {!isCommentsModalOpen && ( - } - useWindowScroll={!isCommentsModalOpen} - components={{ Footer }} - endReached={loadMore} - ref={virtuosoRef} - restoreStateFrom={lastVirtuosoState} - initialScrollTop={lastVirtuosoState?.scrollTop} - /> - )} -
-
- + } + useWindowScroll={true} + components={{ Footer }} + endReached={loadMore} + ref={virtuosoRef} + restoreStateFrom={lastVirtuosoState} + initialScrollTop={lastVirtuosoState?.scrollTop} + />
); From 7ee59b99519bedfc809077aab0e2fff9b9f63565 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 28 Oct 2023 11:40:14 +0200 Subject: [PATCH 2/7] fix(comments buttons): fix flexbox positioning --- .../comments-buttons.module.css | 41 +++++++++++++------ .../comments-buttons/comments-buttons.tsx | 5 ++- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/components/header/comments-buttons/comments-buttons.module.css b/src/components/header/comments-buttons/comments-buttons.module.css index ec420ff7..b82dd82f 100644 --- a/src/components/header/comments-buttons/comments-buttons.module.css +++ b/src/components/header/comments-buttons/comments-buttons.module.css @@ -1,9 +1,12 @@ +.wrapper { + display: flex; +} + .pageName { font-weight: bold; margin-right: 1ex; font-variant: small-caps; font-size: 1.2em; - padding: 43px 0 0 15px; } .pageName a { @@ -15,13 +18,11 @@ list-style: none; white-space: nowrap; display: inline-block; - margin-bottom: -43px; padding-left: 5px; - transform: translateY(0.5px); } _::-webkit-full-page-media, _:future, :root .tabMenu { - margin-bottom: -44px; + transform: translateY(0.5px); } .tabMenu li { @@ -39,19 +40,33 @@ _::-webkit-full-page-media, _:future, :root .tabMenu { border-bottom: 1px solid var(--background); } -@media (max-width: 768px) { - .tabMenu { - padding-top: 49px; - position: absolute; + +@media (min-width: 768px) { + .wrapper { + margin-top: 44px; + margin-left: 15px; } - .tabMenu li a { - line-height: 0px; + .tabMenu { + order: 2; } .pageName { - padding-top: 47px; - position: absolute; - margin-left: 80px; + order: 1; + } +} + +@media (max-width: 768px) { + .wrapper { + margin-top: 47px; + } + + .tabMenu { + order: 1; + margin-right: 5px; + } + + .pageName { + order: 2; } } \ No newline at end of file diff --git a/src/components/header/comments-buttons/comments-buttons.tsx b/src/components/header/comments-buttons/comments-buttons.tsx index 0077fe6e..25ad28d9 100644 --- a/src/components/header/comments-buttons/comments-buttons.tsx +++ b/src/components/header/comments-buttons/comments-buttons.tsx @@ -11,7 +11,7 @@ const CommentsButtons: FC = () => { const { title, shortAddress } = subplebbit || {}; return ( - <> +
{ {t('header_comments')} - + +
); }; From 49d1a32dfb618210788cf715199bb20da9eddd02 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 28 Oct 2023 18:13:08 +0200 Subject: [PATCH 3/7] feat(reply): display link embedded in reply above its content, keep embed button --- .../header/comments-buttons/comments-buttons.tsx | 1 - src/components/reply/reply.module.css | 6 ++++++ src/components/reply/reply.tsx | 11 ++++++++++- src/components/views/comments/comments.tsx | 4 +--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/header/comments-buttons/comments-buttons.tsx b/src/components/header/comments-buttons/comments-buttons.tsx index 25ad28d9..03fdcea1 100644 --- a/src/components/header/comments-buttons/comments-buttons.tsx +++ b/src/components/header/comments-buttons/comments-buttons.tsx @@ -27,7 +27,6 @@ const CommentsButtons: FC = () => { {t('header_comments')} - ); }; diff --git a/src/components/reply/reply.module.css b/src/components/reply/reply.module.css index cd4bf612..bbccf841 100644 --- a/src/components/reply/reply.module.css +++ b/src/components/reply/reply.module.css @@ -77,6 +77,7 @@ .usertext { font-size: small; unicode-bidi: isolate; + margin-top: 5px; } .md { @@ -90,6 +91,11 @@ word-wrap: break-word; } +.usertext a { + color: var(--text); + text-decoration: none; +} + .buttons { list-style-type: none; margin-left: 29px; diff --git a/src/components/reply/reply.tsx b/src/components/reply/reply.tsx index d731d344..015787b6 100644 --- a/src/components/reply/reply.tsx +++ b/src/components/reply/reply.tsx @@ -54,8 +54,17 @@ const Reply: FC = ({ reply }) => {
{hasThumbnail && } {hasThumbnail && } -
{content}
+ {link && ( + <> + + ({link}) + +
+
+ + )} {hasThumbnail && } +
{content}
    diff --git a/src/components/views/comments/comments.tsx b/src/components/views/comments/comments.tsx index c73cf342..777d4490 100644 --- a/src/components/views/comments/comments.tsx +++ b/src/components/views/comments/comments.tsx @@ -37,9 +37,7 @@ const Comments: FC = () => {
    - - {replyCount === 0 ? t('no_comments') : t('all_comments', { count: replyCount })} - + {replyCount === 0 ? t('no_comments') : t('all_comments', { count: replyCount })}
    From 7873689ef70661485e0f306e22f637145146cd97 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 28 Oct 2023 21:08:52 +0200 Subject: [PATCH 4/7] feat(reply): implement vote score, translated --- public/translations/ar/default.json | 4 +++- public/translations/bn/default.json | 4 +++- public/translations/cs/default.json | 4 +++- public/translations/da/default.json | 4 +++- public/translations/de/default.json | 4 +++- public/translations/el/default.json | 4 +++- public/translations/en/default.json | 4 +++- public/translations/es/default.json | 4 +++- public/translations/fa/default.json | 4 +++- public/translations/fi/default.json | 4 +++- public/translations/fil/default.json | 4 +++- public/translations/fr/default.json | 4 +++- public/translations/he/default.json | 4 +++- public/translations/hi/default.json | 4 +++- public/translations/hu/default.json | 4 +++- public/translations/id/default.json | 4 +++- public/translations/it/default.json | 4 +++- public/translations/ja/default.json | 4 +++- public/translations/ko/default.json | 4 +++- public/translations/mr/default.json | 4 +++- public/translations/nl/default.json | 4 +++- public/translations/no/default.json | 4 +++- public/translations/pl/default.json | 4 +++- public/translations/pt/default.json | 4 +++- public/translations/ro/default.json | 4 +++- public/translations/ru/default.json | 4 +++- public/translations/sq/default.json | 4 +++- public/translations/sv/default.json | 4 +++- public/translations/te/default.json | 4 +++- public/translations/th/default.json | 4 +++- public/translations/tr/default.json | 4 +++- public/translations/uk/default.json | 4 +++- public/translations/ur/default.json | 4 +++- public/translations/vi/default.json | 4 +++- public/translations/zh/default.json | 4 +++- src/components/reply/reply.tsx | 9 ++++++++- 36 files changed, 113 insertions(+), 36 deletions(-) diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index 8ce5b106..3fb85524 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -45,5 +45,7 @@ "reply_best": "أفضل", "reply_sorted_by": "مرتبة حسب", "all_comments": "جميع {{count}} التعليقات", - "no_comments": "لا تعليقات (بعد)" + "no_comments": "لا تعليقات (بعد)", + "reply_score_singular": "1 نقطة", + "reply_score_plural": "{{count}} نقاط" } \ No newline at end of file diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index b0a53f4a..e82ba3f0 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -45,5 +45,7 @@ "reply_best": "সেরা", "reply_sorted_by": "অনুসারে বাছাই", "all_comments": "সব {{count}} মন্তব্য", - "no_comments": "কোনো মন্তব্য নেই (এখনো)" + "no_comments": "কোনো মন্তব্য নেই (এখনো)", + "reply_score_singular": "1 পয়েন্ট", + "reply_score_plural": "{{count}} পয়েন্ট" } \ No newline at end of file diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index 7aab6529..5c21fc5b 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -45,5 +45,7 @@ "reply_best": "Nejlepší", "reply_sorted_by": "Řazeno podle", "all_comments": "Všechny {{count}} komentáře", - "no_comments": "Žádné komentáře (zatím)" + "no_comments": "Žádné komentáře (zatím)", + "reply_score_singular": "1 bod", + "reply_score_plural": "{{count}} body" } \ No newline at end of file diff --git a/public/translations/da/default.json b/public/translations/da/default.json index ebffb534..b635ebc7 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -45,5 +45,7 @@ "reply_best": "Bedste", "reply_sorted_by": "Sorteret efter", "all_comments": "Alle {{count}} kommentarer", - "no_comments": "Ingen kommentarer (endnu)" + "no_comments": "Ingen kommentarer (endnu)", + "reply_score_singular": "1 point", + "reply_score_plural": "{{count}} point" } \ No newline at end of file diff --git a/public/translations/de/default.json b/public/translations/de/default.json index 3ae3b292..f8f5594e 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -45,5 +45,7 @@ "reply_best": "Besten", "reply_sorted_by": "Sortiert nach", "all_comments": "Alle {{count}} kommentare", - "no_comments": "Keine kommentare (noch)" + "no_comments": "Keine kommentare (noch)", + "reply_score_singular": "1 Punkt", + "reply_score_plural": "{{count}} Punkte" } \ No newline at end of file diff --git a/public/translations/el/default.json b/public/translations/el/default.json index 6a351b84..99199ac3 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -45,5 +45,7 @@ "reply_best": "Καλύτερα", "reply_sorted_by": "Ταξινομημένα κατά", "all_comments": "Όλα τα {{count}} σχόλια", - "no_comments": "Κανένα σχόλιο (ακόμη)" + "no_comments": "Κανένα σχόλιο (ακόμη)", + "reply_score_singular": "1 βαθμός", + "reply_score_plural": "{{count}} βαθμοί" } \ No newline at end of file diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 27fe14e3..9219f6ac 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -45,5 +45,7 @@ "reply_best": "best", "reply_sorted_by": "sorted by", "all_comments": "all {{count}} comments", - "no_comments": "no comments (yet)" + "no_comments": "no comments (yet)", + "reply_score_singular": "1 point", + "reply_score_plural": "{{count}} points" } \ No newline at end of file diff --git a/public/translations/es/default.json b/public/translations/es/default.json index 0d902ecc..5a46ebcc 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -45,5 +45,7 @@ "reply_best": "mejores", "reply_sorted_by": "ordenado por", "all_comments": "todos los {{count}} comentarios", - "no_comments": "sin comentarios (aún)" + "no_comments": "sin comentarios (aún)", + "reply_score_singular": "1 punto", + "reply_score_plural": "{{count}} puntos" } \ No newline at end of file diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index dd3cb472..e86f8607 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -45,5 +45,7 @@ "reply_best": "بهترین", "reply_sorted_by": "مرتب‌شده بر اساس", "all_comments": "همه {{count}} نظرات", - "no_comments": "بدون نظر (هنوز)" + "no_comments": "بدون نظر (هنوز)", + "reply_score_singular": "1 امتیاز", + "reply_score_plural": "{{count}} امتیاز" } \ No newline at end of file diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index da1ac2b9..d01d3613 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -45,5 +45,7 @@ "reply_best": "Parhaat", "reply_sorted_by": "Lajiteltu", "all_comments": "Kaikki {{count}} kommentit", - "no_comments": "Ei kommentteja (vielä)" + "no_comments": "Ei kommentteja (vielä)", + "reply_score_singular": "1 piste", + "reply_score_plural": "{{count}} pistettä" } \ No newline at end of file diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index c699aa60..2aba37bb 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -45,5 +45,7 @@ "reply_best": "Pinakamahusay", "reply_sorted_by": "Naayos ayon sa", "all_comments": "Lahat ng {{count}} mga komento", - "no_comments": "Walang komento (pa)" + "no_comments": "Walang komento (pa)", + "reply_score_singular": "1 punto", + "reply_score_plural": "{{count}} punto" } \ No newline at end of file diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index 34a592cd..87d0a371 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -45,5 +45,7 @@ "reply_best": "meilleurs", "reply_sorted_by": "trié par", "all_comments": "tous les {{count}} commentaires", - "no_comments": "aucun commentaire (encore)" + "no_comments": "aucun commentaire (encore)", + "reply_score_singular": "1 point", + "reply_score_plural": "{{count}} points" } \ No newline at end of file diff --git a/public/translations/he/default.json b/public/translations/he/default.json index 6f3408d9..d99fef2d 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -45,5 +45,7 @@ "reply_best": "הכי טובים", "reply_sorted_by": "ממוין לפי", "all_comments": "כל {{count}} התגובות", - "no_comments": "אין תגובות (עדיין)" + "no_comments": "אין תגובות (עדיין)", + "reply_score_singular": "1 נקודה", + "reply_score_plural": "{{count}} נקודות" } \ No newline at end of file diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index b94273a5..2742e032 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -45,5 +45,7 @@ "reply_best": "सर्वश्रेष्ठ", "reply_sorted_by": "इसके अनुसार क्रमबद्ध", "all_comments": "सभी {{count}} टिप्पणियां", - "no_comments": "कोई टिप्पणी नहीं (अब तक)" + "no_comments": "कोई टिप्पणी नहीं (अब तक)", + "reply_score_singular": "1 अंक", + "reply_score_plural": "{{count}} अंक" } \ No newline at end of file diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index 3bb46686..2958442e 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -45,5 +45,7 @@ "reply_best": "Legjobb", "reply_sorted_by": "Sorrend", "all_comments": "Mind a {{count}} hozzászólások", - "no_comments": "Nincsenek hozzászólások (még)" + "no_comments": "Nincsenek hozzászólások (még)", + "reply_score_singular": "1 pont", + "reply_score_plural": "{{count}} pont" } \ No newline at end of file diff --git a/public/translations/id/default.json b/public/translations/id/default.json index 546838e9..6b771cae 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -45,5 +45,7 @@ "reply_best": "Terbaik", "reply_sorted_by": "Diurutkan berdasarkan", "all_comments": "Semua {{count}} komentar", - "no_comments": "Tidak ada komentar (belum)" + "no_comments": "Tidak ada komentar (belum)", + "reply_score_singular": "1 poin", + "reply_score_plural": "{{count}} poin" } \ No newline at end of file diff --git a/public/translations/it/default.json b/public/translations/it/default.json index c051530f..2c747194 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -45,5 +45,7 @@ "reply_best": "migliori", "reply_sorted_by": "ordinato per", "all_comments": "tutti i {{count}} commenti", - "no_comments": "nessun commento (ancora)" + "no_comments": "nessun commento (ancora)", + "reply_score_singular": "1 punto", + "reply_score_plural": "{{count}} punti" } \ No newline at end of file diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 1301568b..513c226d 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -45,5 +45,7 @@ "reply_best": "最良", "reply_sorted_by": "ソート条件", "all_comments": "すべての{{count}}コメント", - "no_comments": "コメントはありません(まだ)" + "no_comments": "コメントはありません(まだ)", + "reply_score_singular": "1 ポイント", + "reply_score_plural": "{{count}} ポイント" } \ No newline at end of file diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index 1c8787ff..4c7df155 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -45,5 +45,7 @@ "reply_best": "최고의", "reply_sorted_by": "정렬 기준", "all_comments": "모든 {{count}} 댓글", - "no_comments": "댓글 없음 (아직)" + "no_comments": "댓글 없음 (아직)", + "reply_score_singular": "1 점", + "reply_score_plural": "{{count}} 점" } \ No newline at end of file diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index cd2d95ed..25f02ed3 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -45,5 +45,7 @@ "reply_best": "सर्वोत्कृष्ट", "reply_sorted_by": "याप्रमाणे क्रमवारीत", "all_comments": "सर्व {{count}} टिप्पण्या", - "no_comments": "कोणत्याही टिप्पण्या नाहीत (अजून)" + "no_comments": "कोणत्याही टिप्पण्या नाहीत (अजून)", + "reply_score_singular": "1 गुण", + "reply_score_plural": "{{count}} गुण" } \ No newline at end of file diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index b612c7b2..b1200c17 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -45,5 +45,7 @@ "reply_best": "Beste", "reply_sorted_by": "Gesorteerd op", "all_comments": "Alle {{count}} reacties", - "no_comments": "Geen reacties (nog)" + "no_comments": "Geen reacties (nog)", + "reply_score_singular": "1 punt", + "reply_score_plural": "{{count}} punten" } \ No newline at end of file diff --git a/public/translations/no/default.json b/public/translations/no/default.json index e14304e6..8c631e45 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -45,5 +45,7 @@ "reply_best": "Beste", "reply_sorted_by": "Sortert etter", "all_comments": "Alle {{count}} kommentarer", - "no_comments": "Ingen kommentarer (ennå)" + "no_comments": "Ingen kommentarer (ennå)", + "reply_score_singular": "1 poeng", + "reply_score_plural": "{{count}} poeng" } \ No newline at end of file diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 0f85641f..67a6d866 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -45,5 +45,7 @@ "reply_best": "Najlepsze", "reply_sorted_by": "Sortowane według", "all_comments": "Wszystkie {{count}} komentarze", - "no_comments": "Brak komentarzy (jeszcze)" + "no_comments": "Brak komentarzy (jeszcze)", + "reply_score_singular": "1 punkt", + "reply_score_plural": "{{count}} punkty" } \ No newline at end of file diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 6524f1d4..0358cbce 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -45,5 +45,7 @@ "reply_best": "melhores", "reply_sorted_by": "ordenado por", "all_comments": "todos os {{count}} comentários", - "no_comments": "sem comentários (ainda)" + "no_comments": "sem comentários (ainda)", + "reply_score_singular": "1 ponto", + "reply_score_plural": "{{count}} pontos" } \ No newline at end of file diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index fff81c08..f7a07a49 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -45,5 +45,7 @@ "reply_best": "Cele mai bune", "reply_sorted_by": "Sortat după", "all_comments": "Toate {{count}} comentariile", - "no_comments": "Fără comentarii (încă)" + "no_comments": "Fără comentarii (încă)", + "reply_score_singular": "1 punct", + "reply_score_plural": "{{count}} puncte" } \ No newline at end of file diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index 153748d3..09301370 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -45,5 +45,7 @@ "reply_best": "Лучшие", "reply_sorted_by": "Сортировать по", "all_comments": "Все {{count}} комментарии", - "no_comments": "Нет комментариев (пока)" + "no_comments": "Нет комментариев (пока)", + "reply_score_singular": "1 очко", + "reply_score_plural": "{{count}} очков" } \ No newline at end of file diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index 145ad6f3..8d0c4175 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -45,5 +45,7 @@ "reply_best": "Më të mirët", "reply_sorted_by": "Renditur sipas", "all_comments": "Të gjitha {{count}} komentet", - "no_comments": "Asnjë koment (ende)" + "no_comments": "Asnjë koment (ende)", + "reply_score_singular": "1 pikë", + "reply_score_plural": "{{count}} pikë" } \ No newline at end of file diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index 3fa24f4d..61088256 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -45,5 +45,7 @@ "reply_best": "Bästa", "reply_sorted_by": "Sorterat efter", "all_comments": "Alla {{count}} kommentarer", - "no_comments": "Inga kommentarer (ännu)" + "no_comments": "Inga kommentarer (ännu)", + "reply_score_singular": "1 poäng", + "reply_score_plural": "{{count}} poäng" } \ No newline at end of file diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 4ea5d1af..8a09efdb 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -45,5 +45,7 @@ "reply_best": "ఉత్తమ", "reply_sorted_by": "దీని ప్రకారం క్రమపడబడింది", "all_comments": "అన్ని {{count}} వ్యాఖ్యలు", - "no_comments": "వ్యాఖ్యలు లేవు (ఇంకా)" + "no_comments": "వ్యాఖ్యలు లేవు (ఇంకా)", + "reply_score_singular": "1 పాయింట్", + "reply_score_plural": "{{count}} పాయింట్లు" } \ No newline at end of file diff --git a/public/translations/th/default.json b/public/translations/th/default.json index 043ef13f..03b39c24 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -45,5 +45,7 @@ "reply_best": "ที่สุด", "reply_sorted_by": "เรียงลำดับตาม", "all_comments": "ความคิดเห็น {{count}} รายการทั้งหมด", - "no_comments": "ไม่มีความคิดเห็น (ยัง)" + "no_comments": "ไม่มีความคิดเห็น (ยัง)", + "reply_score_singular": "1 แต้ม", + "reply_score_plural": "{{count}} แต้ม" } \ No newline at end of file diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index f98444ae..f6554d6e 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -45,5 +45,7 @@ "reply_best": "En iyiler", "reply_sorted_by": "Şuna göre sırala", "all_comments": "Tüm {{count}} yorumlar", - "no_comments": "Yorum yok (henüz)" + "no_comments": "Yorum yok (henüz)", + "reply_score_singular": "1 puan", + "reply_score_plural": "{{count}} puan" } \ No newline at end of file diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index c8cd07ef..1352e466 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -45,5 +45,7 @@ "reply_best": "Найкращі", "reply_sorted_by": "Сортувати за", "all_comments": "Всі {{count}} коментарі", - "no_comments": "Немає коментарів (ще)" + "no_comments": "Немає коментарів (ще)", + "reply_score_singular": "1 бал", + "reply_score_plural": "{{count}} бали" } \ No newline at end of file diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index c0c70ae9..2e8be02d 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -45,5 +45,7 @@ "reply_best": "بہترین", "reply_sorted_by": "کے مطابق ترتیب", "all_comments": "تمام {{count}} تبصرے", - "no_comments": "کوئی تبصرہ نہیں (ابھی)" + "no_comments": "کوئی تبصرہ نہیں (ابھی)", + "reply_score_singular": "1 پوائنٹ", + "reply_score_plural": "{{count}} پوائنٹس" } \ No newline at end of file diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index d4b7f9ff..7b21f3ae 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -45,5 +45,7 @@ "reply_best": "Tốt nhất", "reply_sorted_by": "Sắp xếp theo", "all_comments": "Tất cả {{count}} bình luận", - "no_comments": "Không có bình luận (chưa)" + "no_comments": "Không có bình luận (chưa)", + "reply_score_singular": "1 điểm", + "reply_score_plural": "{{count}} điểm" } \ No newline at end of file diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index bf8d27fe..ceab86b2 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -45,5 +45,7 @@ "reply_best": "最好的", "reply_sorted_by": "排序方式", "all_comments": "全部 {{count}} 个评论", - "no_comments": "暂无评论(还)" + "no_comments": "暂无评论(还)", + "reply_score_singular": "1 分", + "reply_score_plural": "{{count}} 分" } \ No newline at end of file diff --git a/src/components/reply/reply.tsx b/src/components/reply/reply.tsx index 015787b6..84c4cade 100644 --- a/src/components/reply/reply.tsx +++ b/src/components/reply/reply.tsx @@ -18,8 +18,10 @@ const Reply: FC = ({ reply }) => { cid, content, depth, + downvoteCount, link, timestamp, + upvoteCount, } = reply || {}; const replies = useReplies(reply); const [expanded, setExpanded] = useState(false); @@ -27,6 +29,11 @@ const Reply: FC = ({ reply }) => { const commentMediaInfo = utils.getCommentMediaInfoMemoized(reply); const hasThumbnail = utils.hasThumbnail(commentMediaInfo, link); const { t } = useTranslation(); + let score = upvoteCount - downvoteCount; + if ((upvoteCount === 0 && downvoteCount === 0) || (upvoteCount === 1 && downvoteCount === 0)) { + score = 1; + } + const scoreTranslation = score === 1 ? t('reply_score_singular') : t('reply_score_plural', { count: score }); return (
    @@ -47,7 +54,7 @@ const Reply: FC = ({ reply }) => { > {shortAddress} - 1 point + {scoreTranslation}   {utils.getFormattedTime(timestamp)}

    From 09193264ccddb98cab96515b0d3db56a3ec8e4b5 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 28 Oct 2023 21:23:59 +0200 Subject: [PATCH 5/7] refactor: only export one component per file --- src/components/header/header.tsx | 3 ++- src/components/header/index.ts | 5 +---- src/components/post/index.ts | 8 +------- src/components/reply/reply.tsx | 4 +++- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/header/header.tsx b/src/components/header/header.tsx index 7f57a3b0..34340fb1 100644 --- a/src/components/header/header.tsx +++ b/src/components/header/header.tsx @@ -4,7 +4,8 @@ import { useTranslation } from 'react-i18next'; import styles from './header.module.css'; import useTheme from '../../hooks/use-theme'; import AccountBar from './account-bar'; -import { SortButtons, CommentsButtons } from '../header'; +import CommentsButtons from '../header/comments-buttons'; +import SortButtons from '../header/sort-buttons'; // prettier-ignore const availableLanguages = ['ar', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fil', 'fr', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'mr', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sq', 'sv', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh']; diff --git a/src/components/header/index.ts b/src/components/header/index.ts index f7a1b03e..f617627a 100644 --- a/src/components/header/index.ts +++ b/src/components/header/index.ts @@ -1,4 +1 @@ -export {default} from './header'; -export {default as AccountBar} from './account-bar'; -export {default as SortButtons} from './sort-buttons'; -export {default as CommentsButtons} from './comments-buttons'; \ No newline at end of file +export {default} from './header'; \ No newline at end of file diff --git a/src/components/post/index.ts b/src/components/post/index.ts index dbc3d829..4a8416c5 100644 --- a/src/components/post/index.ts +++ b/src/components/post/index.ts @@ -1,7 +1 @@ -export {default} from './post' -export {default as Embed} from './embed' -export {default as Expando} from './expando' -export {default as ExpandButton} from './expand-button' -export {default as Flair} from './flair' -export {default as PostTools} from './post-tools' -export {default as Thumbnail} from './thumbnail' \ No newline at end of file +export {default} from './post'; \ No newline at end of file diff --git a/src/components/reply/reply.tsx b/src/components/reply/reply.tsx index 84c4cade..e0d107f8 100644 --- a/src/components/reply/reply.tsx +++ b/src/components/reply/reply.tsx @@ -5,7 +5,9 @@ import { useTranslation } from 'react-i18next'; import styles from './reply.module.css'; import useReplies from '../../hooks/use-replies'; import utils from '../../lib/utils'; -import { Thumbnail, Expando, ExpandButton } from '../post'; +import Expando from '../post/expando/'; +import ExpandButton from '../post/expand-button/'; +import Thumbnail from '../post/thumbnail/'; interface ReplyProps { key: number; From e607fa7b33f545ab2863be82923c9cbf5a009f70 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 28 Oct 2023 21:34:32 +0200 Subject: [PATCH 6/7] perf(app): use route outlet for home layout --- src/app.tsx | 18 +++++-- .../views/comments/comments.module.css | 10 ---- src/components/views/comments/comments.tsx | 48 ++++++++----------- src/components/views/home/home.tsx | 4 -- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index f3876f67..c004e64f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,9 +1,11 @@ import { useEffect } from 'react'; -import { Route, Routes } from 'react-router-dom'; +import { Outlet, Route, Routes } from 'react-router-dom'; import useTheme from './hooks/use-theme'; import styles from './app.module.css'; import Home from './components/views/home'; import Comments from './components/views/comments'; +import TopBar from './components/topbar/topbar'; +import Header from './components/header/header'; function App() { const [theme] = useTheme(); @@ -13,11 +15,21 @@ function App() { document.body.classList.add(theme); }, [theme]); + const homeLayout = ( + <> + +
    + + + ); + return (
    - } /> - } /> + + } /> + } /> +
    ); diff --git a/src/components/views/comments/comments.module.css b/src/components/views/comments/comments.module.css index 967f3dab..ef28411e 100644 --- a/src/components/views/comments/comments.module.css +++ b/src/components/views/comments/comments.module.css @@ -1,13 +1,3 @@ -.content { - position: fixed; - top: 0; - width: 100%; - height: 100%; - overflow-x: hidden; - z-index: 999; - background-color: var(--background); -} - .comments { padding: 7px 5px 0px 5px; margin-bottom: 200px; diff --git a/src/components/views/comments/comments.tsx b/src/components/views/comments/comments.tsx index 777d4490..948d99f0 100644 --- a/src/components/views/comments/comments.tsx +++ b/src/components/views/comments/comments.tsx @@ -3,8 +3,6 @@ import { useParams } from 'react-router-dom'; import { useComment, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import { useTranslation } from 'react-i18next'; import styles from './comments.module.css'; -import TopBar from '../../topbar'; -import Header from '../../header'; import Post from '../../post'; import useReplies from '../../../hooks/use-replies'; import Reply from '../../reply/reply'; @@ -29,37 +27,31 @@ const Comments: FC = () => { }, [threadTitle, subplebbitTitle]); return ( - <> -
    - -
    -
    - -
    -
    - {replyCount === 0 ? t('no_comments') : t('all_comments', { count: replyCount })} +
    + +
    +
    + {replyCount === 0 ? t('no_comments') : t('all_comments', { count: replyCount })} +
    +
    +
    + {t('reply_sorted_by')}:  +
    + {t('reply_best')}
    -
    -
    - {t('reply_sorted_by')}:  -
    - {t('reply_best')} -
    -
    -
    -
    -