feat(SW-1542): Carousel component * feat(SW-1542): add Embla Carousel component and use in CarouselCards * fix(SW-1542): remove max-width constraint for card on ipad * fix(SW-1542): Add padding to start page content container * refactor(SW-1542): Improve Embla Carousel type imports * refactor(SW-1542): Remove unnecessary carousel wrapper div * refactor(SW-1542): Modularize Carousel component structure * refactor(SW-1542): Remove carousel dots display * feat(SW-1542): Add carousel dots navigation * refactor(SW-1542): Update Carousel component styling and types * refactor(SW-1542): Remove uneeded useCallback from Carousel navigation methods * refactor(SW-1542): Modify CarouselContextProps type to exclude className * refactor(SW-1542): Optimize React imports in Carousel components * refactor(SW-1542): Consolidate Carousel component and remove CarouselRoot * refactor(SW-1542): Update Carousel navigation methods to use function-based scroll checks * refactor(SW-1542): Add explicit children prop support to CarouselContent component * refactor(SW-1542): Add children prop support to CarouselItem component Approved-by: Christian Andolf
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
"use client"
|
|
|
|
import { useState } from "react"
|
|
|
|
import { Carousel } from "@/components/Carousel"
|
|
import ContentCard from "@/components/ContentCard"
|
|
import SectionContainer from "@/components/Section/Container"
|
|
import SectionHeader from "@/components/Section/Header"
|
|
import SectionLink from "@/components/Section/Link"
|
|
|
|
import Filters from "./Filters"
|
|
|
|
import styles from "./carouselCards.module.css"
|
|
|
|
import type { CarouselCardsProps } from "@/types/components/blocks/carouselCards"
|
|
|
|
export default function CarouselCards({ carousel_cards }: CarouselCardsProps) {
|
|
const {
|
|
heading,
|
|
enableFilters,
|
|
defaultFilter,
|
|
filterCategories,
|
|
cards,
|
|
link,
|
|
} = carousel_cards
|
|
|
|
const [activeFilter, setActiveFilter] = useState(
|
|
enableFilters ? defaultFilter : null
|
|
)
|
|
|
|
const filteredCards = !activeFilter
|
|
? cards
|
|
: cards.filter(
|
|
(card) => "filterId" in card && card.filterId === activeFilter
|
|
)
|
|
|
|
return (
|
|
<SectionContainer>
|
|
<SectionHeader title={heading} link={link} />
|
|
{filterCategories.length > 0 && activeFilter && (
|
|
<Filters
|
|
categories={filterCategories}
|
|
selectedFilter={activeFilter}
|
|
onFilterSelect={setActiveFilter}
|
|
/>
|
|
)}
|
|
<Carousel>
|
|
<Carousel.Content>
|
|
{filteredCards.map((card, index) => (
|
|
<Carousel.Item key={`${card.heading}-${index}`}>
|
|
<ContentCard
|
|
heading={card.heading}
|
|
image={card.image}
|
|
bodyText={card.bodyText}
|
|
promoText={card.promoText}
|
|
link={card.link}
|
|
/>
|
|
</Carousel.Item>
|
|
))}
|
|
</Carousel.Content>
|
|
<Carousel.Previous className={styles.navigationButton} />
|
|
<Carousel.Next className={styles.navigationButton} />
|
|
<Carousel.Dots />
|
|
</Carousel>
|
|
<SectionLink link={link} variant="mobile" />
|
|
</SectionContainer>
|
|
)
|
|
}
|