Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use list table in section and subsections, but not articles #755 #756

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions app/components/Article/KeepGoing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {Question, RelatedQuestion} from '~/server-utils/stampy'
import {questionUrl} from '~/routesMapper'
import styles from './keepGoing.module.css'

const nonContinueSections = ['8TJV']
const sectionsWithListTable = ['8TJV']

type NextArticleProps = {
section?: TOCItem
Expand Down Expand Up @@ -43,7 +43,12 @@ export const KeepGoing = ({pageid, relatedQuestions}: Question) => {
const section = findSection(location?.state?.section || pageid)
const next = getNext(pageid, section?.pageid)
const hasRelated = relatedQuestions && relatedQuestions.length > 0
const skipNext = nonContinueSections.includes(section?.pageid || '')
const showListTable =
// used on section and sub-sections, but not on leaf articles
sectionsWithListTable.includes(pageid) ||
(section &&
sectionsWithListTable.includes(section.pageid) &&
section.children?.some((c) => c.pageid == pageid))

const formatRelated = (hasIcon: boolean) => (related: RelatedQuestion) => {
const relatedSection = findSection(related.pageid)
Expand All @@ -54,25 +59,23 @@ export const KeepGoing = ({pageid, relatedQuestions}: Question) => {

return (
<div>
{!skipNext && (
<NextArticle section={section} next={next} first={section?.pageid === pageid} />
)}

{next && hasRelated && !skipNext && (
<div className="padding-bottom-24">Or jump to a related question</div>
)}
{hasRelated && !skipNext && (
<div>
<ListTable elements={relatedQuestions.slice(0, 3).map(formatRelated(true))} />
</div>
)}
{skipNext && (
<div>
<ListTable
sameTab
elements={getArticle(pageid)?.children?.map(formatRelated(false)) || []}
/>
</div>
{showListTable ? (
<ListTable
sameTab
elements={getArticle(pageid)?.children?.map(formatRelated(false)) || []}
/>
) : (
<>
<NextArticle section={section} next={next} first={section?.pageid === pageid} />
{next && hasRelated && (
<div className="padding-bottom-24">Or jump to a related question</div>
)}
{hasRelated && (
<div>
<ListTable elements={relatedQuestions.slice(0, 3).map(formatRelated(true))} />
</div>
)}
</>
)}
</div>
)
Expand Down
Loading