Files
web/apps/scandic-web/components/Blocks/Accordion/index.tsx
Erik Tiekstra 333636c81a Merged in feat/BOOK-61-refactor-hotel-page-css-variables (pull request #3014)
Feat/BOOK-61 refactor hotel page css variables

* feat(BOOK-61): Breadcrumbs

* feat(BOOK-61): intro section

* feat(BOOK-61): show more button

* feat(BOOK-61): rooms section

* feat(BOOK-61): sidepeeks

* feat(BOOK-61): deprecated old Link component

* feat(BOOK-61): added new TextLink component to the design-system

* feat(BOOK-61): replaced deprecated links with new TextLink component

* feat(BOOK-61): miscellaneous changes


Approved-by: Bianca Widstam
Approved-by: Christel Westerberg
2025-10-29 09:15:03 +00:00

57 lines
1.8 KiB
TypeScript

"use client"
import { cx } from "class-variance-authority"
import { useState } from "react"
import Accordion from "@scandic-hotels/design-system/Accordion"
import AccordionItem from "@scandic-hotels/design-system/Accordion/AccordionItem"
import { JsonToHtml } from "@scandic-hotels/design-system/JsonToHtml"
import { Section } from "@/components/Section"
import { SectionHeader } from "@/components/Section/Header"
import ShowMoreButton from "@/components/TempDesignSystem/ShowMoreButton"
import styles from "./accordion.module.css"
import type { AccordionProps } from "@/types/components/blocks/Accordion"
import { HotelHashValues } from "@/types/enums/hotelPage"
export default function AccordionSection({ accordion, title }: AccordionProps) {
const showToggleButton = accordion.length > 5
const [allAccordionsVisible, setAllAccordionsVisible] =
useState(!showToggleButton)
function toggleAccordions() {
setAllAccordionsVisible((state) => !state)
}
return (
<Section className={styles.accordionSection} id={HotelHashValues.faq}>
<SectionHeader heading={title} typography="Title/md" />
<Accordion
className={cx(styles.accordion, {
[styles.allVisible]: allAccordionsVisible,
})}
>
{accordion.map((acc) =>
acc ? (
<AccordionItem key={acc.question} title={acc.question}>
<JsonToHtml
embeds={acc.answer.embedded_itemsConnection.edges}
nodes={acc.answer.json.children}
/>
</AccordionItem>
) : null
)}
</Accordion>
{showToggleButton ? (
<ShowMoreButton
loadMoreData={toggleAccordions}
showLess={allAccordionsVisible}
/>
) : null}
</Section>
)
}