From c3973ddd1af0ca3486aa5735f63e5efc88dc51aa Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Mon, 23 Mar 2026 22:13:21 +0100 Subject: [PATCH] Add the Frequently Asked Questions component to website --- .../web/FrequentlyAskedQuestions.astro | 22 ++++++++++++ .../web/subcomponents/QuestionList.tsx | 34 +++++++++++++++++++ astro/src/components/webpage/Webpage.astro | 2 ++ astro/src/types/components/faq.d.ts | 2 +- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 astro/src/components/web/FrequentlyAskedQuestions.astro create mode 100644 astro/src/components/web/subcomponents/QuestionList.tsx diff --git a/astro/src/components/web/FrequentlyAskedQuestions.astro b/astro/src/components/web/FrequentlyAskedQuestions.astro new file mode 100644 index 0000000..986adc1 --- /dev/null +++ b/astro/src/components/web/FrequentlyAskedQuestions.astro @@ -0,0 +1,22 @@ +--- +import { markdownToHtml } from '@/lib/markdown'; +import { QuestionList } from '@/components/web/subcomponents/QuestionList.tsx'; + +interface Props { + faq: FrequentlyAskedQuestionsComponent; +} + +const faq = Astro.props.faq; +--- + +
+
+

{faq.title}

+ { faq.text !== null && ( +
+ ) } +
+
+ +
+
diff --git a/astro/src/components/web/subcomponents/QuestionList.tsx b/astro/src/components/web/subcomponents/QuestionList.tsx new file mode 100644 index 0000000..5b8271e --- /dev/null +++ b/astro/src/components/web/subcomponents/QuestionList.tsx @@ -0,0 +1,34 @@ +import { useState } from "preact/hooks"; + +export function QuestionList(props: { questions: FrequentlyAskedQuestion[]; }) { + const [ open, setOpen ] = useState(null); + + const toggle = (index: number) => { + setOpen(open === index ? null : index); + }; + + return ( +
+ { props.questions.map((question, index: number) => ( +
toggle(index)} + key={index} + className={`w-full overflow-hidden border-l border-r border-t ${open === index && "bg-amber-200"} ${index !== 0 && (index + 1 !== props.questions.length) && "border-amber-300"} ${index === 0 && "rounded-t-2xl border-t border-amber-300"} ${(index + 1) === props.questions.length && "rounded-b-2xl border-b border-amber-300 shadow-md"}`} + > +

{ question.question }

+
+
+
+ {question.answer} +
+
+
+
+ )) } +
+ ) +} diff --git a/astro/src/components/webpage/Webpage.astro b/astro/src/components/webpage/Webpage.astro index 4c51473..183bd54 100644 --- a/astro/src/components/webpage/Webpage.astro +++ b/astro/src/components/webpage/Webpage.astro @@ -1,4 +1,5 @@ --- +import FrequentlyAskedQuestions from '../web/FrequentlyAskedQuestions.astro'; import Hero from '../web/Hero.astro'; import TextWithImage from '../web/TextWithImage.astro'; import UpcomingEvents from '../web/UpcomingEvents.astro'; @@ -20,6 +21,7 @@ console.log(Astro.props.webpage); { component.component === "TextWithImage" && } { component.component === "WallOfText" && } { component.component === "UpcomingEvents" && } + { component.component === "FrequentlyAskedQuestions" && } )) } diff --git a/astro/src/types/components/faq.d.ts b/astro/src/types/components/faq.d.ts index af7f828..405053f 100644 --- a/astro/src/types/components/faq.d.ts +++ b/astro/src/types/components/faq.d.ts @@ -3,7 +3,7 @@ type FrequentlyAskedQuestionsComponent = { id: string; title: string; - text: string; + text: string | null; questions: FrequentlyAskedQuestion[]; }