FAQ accordion component with dummy values
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
--color-ecsess-400: #5C8A5C;
|
--color-ecsess-400: #5C8A5C;
|
||||||
--color-ecsess-600: #3B6A3A;
|
--color-ecsess-600: #3B6A3A;
|
||||||
--color-ecsess-800: #0A3D2A;
|
--color-ecsess-800: #0A3D2A;
|
||||||
|
--color-ecsess-black-hover:#2c2c2c;
|
||||||
--color-ecsess-black: #1F1F1F;
|
--color-ecsess-black: #1F1F1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<script>
|
||||||
|
import { slide } from "svelte/transition";
|
||||||
|
import '/src/app.css';
|
||||||
|
export let entry;
|
||||||
|
const { title, description } = entry;
|
||||||
|
let isOpen = false;
|
||||||
|
const toggle = () => (isOpen = !isOpen);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="accordion-wrapper">
|
||||||
|
<div class="accordion-item {isOpen ? 'open' : ''}">
|
||||||
|
<button
|
||||||
|
class="accordion-header"
|
||||||
|
on:click={toggle}
|
||||||
|
aria-expanded={isOpen}
|
||||||
|
>
|
||||||
|
<span class="title">{title}</span>
|
||||||
|
<svg
|
||||||
|
class="accordion-icon"
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M9 5l7 7-7 7" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{#if isOpen}
|
||||||
|
<div class="accordion-content" transition:slide={{ duration: 300 }}>
|
||||||
|
<p>{@html description}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.accordion-wrapper {
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-item {
|
||||||
|
border: 2px solid var(--color-ecsess-200);
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
height: 64px;
|
||||||
|
padding: 0 1rem;
|
||||||
|
width: 100%;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-header:hover {
|
||||||
|
background-color: var(--color-ecsess-black-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-icon {
|
||||||
|
transition: transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
[aria-expanded="true"] .accordion-icon {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-content {
|
||||||
|
max-height: 100px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 1rem;
|
||||||
|
border-top: 1px solid var(--color-ecsess-200);
|
||||||
|
color: var(--color-ecsess-200);
|
||||||
|
background-color: transparent;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accordion-item.open .accordion-header,
|
||||||
|
.accordion-item.open .accordion-content {
|
||||||
|
background-color: var(--color-ecsess-black-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import FaqAccordion from 'components/FAQAccordion.svelte';
|
||||||
import Section from 'components/Section.svelte';
|
import Section from 'components/Section.svelte';
|
||||||
|
|
||||||
// Getting info from ECSESS CMS
|
// Getting info from ECSESS CMS
|
||||||
// let description =
|
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.';
|
||||||
// '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 query = '_type:homepage';
|
||||||
|
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
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 description = $state();
|
let description = $state();
|
||||||
description = fetch(
|
description = fetch(
|
||||||
@@ -27,10 +42,13 @@
|
|||||||
<Section black>
|
<Section black>
|
||||||
<div class="flex justify-around gap-12">
|
<div class="flex justify-around gap-12">
|
||||||
<div>
|
<div>
|
||||||
<p>PICTURES</p>
|
<h1>PICTURES</h1>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>FAQ</p>
|
<h1>FAQ</h1>
|
||||||
|
{#each data as { q, a }}
|
||||||
|
<FaqAccordion entry={{ title: q, description: a }} />
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
Reference in New Issue
Block a user