diff --git a/src/liff/assets/multiple-replies.png b/src/liff/assets/multiple-replies.png new file mode 100644 index 00000000..b34c20c6 Binary files /dev/null and b/src/liff/assets/multiple-replies.png differ diff --git a/src/liff/pages/Article.svelte b/src/liff/pages/Article.svelte index 0295dfa8..2729d0cb 100644 --- a/src/liff/pages/Article.svelte +++ b/src/liff/pages/Article.svelte @@ -10,9 +10,11 @@ import ArticleReplyCard from '../components/ArticleReplyCard.svelte'; import Spacer from '../components/Spacer.svelte'; import Terms from '../components/Terms.svelte'; + import Button from '../components/Button.svelte'; import { ArticleReplyCard_articleReply } from '../components/fragments'; import { getArticleURL } from 'src/lib/sharedUtils'; import improveBanner from '../assets/improve-reply-banner.png'; + import multipleRepliesBanner from '../assets/multiple-replies.png'; const params = new URLSearchParams(location.search); const articleId = params.get('articleId'); @@ -21,6 +23,9 @@ let articleData; let articleReplies = []; + // These article replies are collapsed by default. Used when replyId is specified from URL. + let collapsedArticleReplies = []; + let expanded = false; // Collapse above article replies by default let createdAt; const loadData = async () => { @@ -44,7 +49,8 @@ const {articleReplies: list, ...rest} = GetArticle; - articleReplies = list.filter(({reply}) => replyId ? reply.id === replyId : true); + articleReplies = !replyId ? list : list.filter(({reply}) => reply.id === replyId); + collapsedArticleReplies = !replyId ? [] : list.filter(({reply}) => reply.id !== replyId); articleData = rest; createdAt = new Date(articleData.createdAt); @@ -101,6 +107,20 @@ margin-top: 24px; width: 100%; } + + .multiple-replies-banner { + margin-top: 24px; + padding: 24px 16px; + background: var(--primary50); + display: grid; + grid-auto-flow: row; + row-gap: 16px; + } + + .multiple-replies-banner > img { + width: 72.8%; + margin: 0 auto; + } @@ -140,9 +160,34 @@ {/if} {/each} - - Help improve replies - + + {#if collapsedArticleReplies.length > 0 } + {#if expanded} +
+ {t`Other replies`} +
+ {#each collapsedArticleReplies as articleReply, idx (articleReply.reply.id)} + {#if idx > 0} + + {/if} + + {/each} + {:else} +
+ Multiple replies available + {t`There are different replies for the message. We suggest read them all here before you make judgements.`} + +
+ {/if} + {/if} + + {#if collapsedArticleReplies.length === 0 || expanded} + + Help improve replies + + {/if} {/if} {/if}