From a95a9d77017fab689c221fba4e9b6b39a14e396b Mon Sep 17 00:00:00 2001 From: zzzmlssqnzzz Date: Mon, 9 Jun 2025 22:55:20 -0400 Subject: [PATCH 1/3] FAQ accordion component with dummy values --- src/app.css | 1 + src/components/FAQAccordion.svelte | 101 +++++++++++++++++++++++++++++ src/routes/+page.svelte | 26 ++++++-- 3 files changed, 124 insertions(+), 4 deletions(-) diff --git a/src/app.css b/src/app.css index 4980f7f..af4cd33 100644 --- a/src/app.css +++ b/src/app.css @@ -8,6 +8,7 @@ --color-ecsess-400: #5C8A5C; --color-ecsess-600: #3B6A3A; --color-ecsess-800: #0A3D2A; + --color-ecsess-black-hover:#2c2c2c; --color-ecsess-black: #1F1F1F; } diff --git a/src/components/FAQAccordion.svelte b/src/components/FAQAccordion.svelte index e69de29..c56bbba 100644 --- a/src/components/FAQAccordion.svelte +++ b/src/components/FAQAccordion.svelte @@ -0,0 +1,101 @@ + + +
+
+ + + {#if isOpen} +
+

{@html description}

+
+ {/if} +
+
+ + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1c5657a..39aaac8 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,10 +1,25 @@ -
-
- +
+
+ - {#if isOpen} -
-

{@html description}

-
- {/if} -
+ {#if isOpen} +
+

{@html description}

+
+ {/if} +
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8ad857f..eb0d88d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -7,28 +7,23 @@ let { data } = $props(); // Getting info from ECSESS CMS - let longAnswer = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; - const query = '_type:homepage'; - - const faqs = [ - { - q: "A fequently asked question?", - a: "This is a short answer", - }, - { - q: "A fequently asked question?", - a: "This is a medium length answer. Lor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - }, - { - q: "A fequently asked question?", - a: "This is a long answer. "+longAnswer - } - ]; + let longAnswer = + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; - let description = $state(); - description = fetch( - `https://${import.meta.env.SANITY_ID}.api.sanity.io/vX/data/query/production?query=${query}&perspective=drafts` - ).then((res) => res.json).then((json) => json.toString()); + const faqs = [ + { + q: 'A fequently asked question?', + a: 'This is a short answer' + }, + { + q: 'A fequently asked question?', + a: 'This is a medium length answer. Lor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' + }, + { + q: 'A fequently asked question?', + a: 'This is a long answer. ' + longAnswer + } + ]; McGill ECSESS @@ -52,7 +47,7 @@

FAQ

{#each faqs as { q, a }} - + {/each}
@@ -63,4 +58,3 @@

Under development

- From 469bc6ba85146ea36dae4274f94bcc9a6a0a4f1a Mon Sep 17 00:00:00 2001 From: Antoine Phan Date: Sat, 14 Jun 2025 01:08:49 -0400 Subject: [PATCH 3/3] FAQ Accordion using Skeleton UI --- src/components/FAQAccordion.svelte | 87 +++++++++++++++++++++++++----- src/routes/+page.server.js | 21 ++++++-- src/routes/+page.svelte | 23 +------- 3 files changed, 92 insertions(+), 39 deletions(-) diff --git a/src/components/FAQAccordion.svelte b/src/components/FAQAccordion.svelte index a4d5669..34ed63a 100644 --- a/src/components/FAQAccordion.svelte +++ b/src/components/FAQAccordion.svelte @@ -1,12 +1,68 @@ -
+ + {#snippet iconClosed()} + + + {/snippet} + {#snippet iconOpen()} + + + {/snippet} + + {#each entries as entry, index} + + + {#snippet lead()} + {entry.question} + {/snippet} + {#snippet control()}{/snippet} + + + {#snippet panel()}{entry.answer}{/snippet} + + {/each} + + + - + --> diff --git a/src/routes/+page.server.js b/src/routes/+page.server.js index 23207c0..97378eb 100644 --- a/src/routes/+page.server.js +++ b/src/routes/+page.server.js @@ -2,7 +2,8 @@ import { getFromCMS } from 'utils/utils.js'; const homepageQuery = `*[_type == "homepage"]{ "description": description[], - "councilPhoto": councilPhoto.asset->url + "councilPhoto": councilPhoto.asset->url, + "faqs": faqs[]{ question, answer }, }[0]`; const ohQuery = `*[_type=="oh"].schedule[]{ @@ -13,12 +14,26 @@ const ohQuery = `*[_type=="oh"].schedule[]{ }`; export const load = async () => { + /** + * @description Response data type based on the `homepageQuery` above. + * Note that `description` is a rich/portable text type + * + * @type {{ + * description: import('@portabletext/svelte').InputValue, + * councilPhoto: string, + * faqs: [{ + * question: string, + * answer: string + * }], + * }} + * + */ let CMSresponse = await getFromCMS(homepageQuery); return { description: CMSresponse.description, - councilPhoto: CMSresponse.councilPhoto + councilPhoto: CMSresponse.councilPhoto, + faqs: CMSresponse.faqs // ohs: await getFromCMS(ohQuery), - // FAQs: "", }; }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index eb0d88d..e2c54cf 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -5,25 +5,6 @@ /** loading things from the server side */ let { data } = $props(); - - // Getting info from ECSESS CMS - let longAnswer = - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; - - const faqs = [ - { - q: 'A fequently asked question?', - a: 'This is a short answer' - }, - { - q: 'A fequently asked question?', - a: 'This is a medium length answer. Lor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' - }, - { - q: 'A fequently asked question?', - a: 'This is a long answer. ' + longAnswer - } - ]; McGill ECSESS @@ -46,9 +27,7 @@

FAQ

- {#each faqs as { q, a }} - - {/each} +