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

hide in-progress banner in sub-sections #753 #754

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions app/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,24 @@ type ArticleProps = {
}
export const Article = ({question, glossary, className}: ArticleProps) => {
const {title, text, pageid} = question
console.debug('gg')

return (
<article className={`${className} ${isLoading(question) ? 'loading' : ''}`}>
<h1 className="teal-500 padding-bottom-24">{title}</h1>
{question.banners?.filter((b) => b.title).map(Banner)}
<ArticleMeta question={question} className="padding-bottom-56" />

<Contents
className="padding-bottom-80"
pageid={pageid}
html={text || ''}
glossary={glossary || {}}
/>
{text ? (
<Contents
className="padding-bottom-80"
pageid={pageid}
html={text}
glossary={glossary || {}}
/>
) : (
<div className="padding-bottom-32" />
)}

<KeepGoing {...question} />

Expand Down
13 changes: 11 additions & 2 deletions app/routes/questions.$questionId.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ const updateRelated = (question: Question, allQuestions?: Question[]) => {
}
}

const updateFields = (question: Question, tags?: Tag[], allQuestions?: Question[]) =>
updateTags(updateRelated(question, allQuestions), tags)
const updateBanners = (question: Question, hideBanners?: boolean) =>
hideBanners ? {...question, banners: []} : question

const updateFields = (
question: Question,
hideBanners?: boolean,
tags?: Tag[],
allQuestions?: Question[]
) => updateTags(updateRelated(updateBanners(question, hideBanners), allQuestions), tags)

export default function RenderArticle() {
const location = useLocation()
Expand All @@ -80,6 +87,7 @@ export default function RenderArticle() {
const {question} = useLoaderData<typeof loader>()
const {toc, findSection, getArticle, getPath} = useToC()
const section = findSection(location?.state?.section || pageid)
const hideBannersIfSubsection = section?.children?.some((c) => c.pageid === pageid)

useEffect(() => {
setShowNav(false)
Expand Down Expand Up @@ -153,6 +161,7 @@ export default function RenderArticle() {
<Article
question={updateFields(
resolvedQuestion.data as Question,
hideBannersIfSubsection,
tags,
onSiteQuestions
)}
Expand Down
Loading