Merged in feat/SW-1443-card-gallery-destination-overview (pull request #1362)
feat(SW-1443): added cardGallery block to destination overview page instead of carousel functionality * feat(SW-1443): added cardGallery block to destination overview page instead of carousel functionality Approved-by: Fredrik Thorsson
This commit is contained in:
25
components/Blocks/CardGallery/cardGallery.module.css
Normal file
25
components/Blocks/CardGallery/cardGallery.module.css
Normal file
@@ -0,0 +1,25 @@
|
||||
.cardsList {
|
||||
list-style: none;
|
||||
display: none;
|
||||
gap: var(--Spacing-x4) var(--Spacing-x1);
|
||||
}
|
||||
|
||||
.navigationButton {
|
||||
top: 30%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.carousel {
|
||||
display: none;
|
||||
}
|
||||
.cardsList {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1024px) {
|
||||
.cardsList {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
67
components/Blocks/CardGallery/index.tsx
Normal file
67
components/Blocks/CardGallery/index.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
"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 TabFilters from "@/components/TabFilters"
|
||||
|
||||
import styles from "./cardGallery.module.css"
|
||||
|
||||
import type { CardGalleryProps } from "@/types/components/blocks/cardGallery"
|
||||
|
||||
export default function CardGallery({ card_gallery }: CardGalleryProps) {
|
||||
const { heading, defaultFilter, filterCategories, cards, link } = card_gallery
|
||||
|
||||
const [activeFilter, setActiveFilter] = useState(defaultFilter)
|
||||
|
||||
const filteredCards = cards.filter((card) => card.filterId === activeFilter)
|
||||
|
||||
return (
|
||||
<SectionContainer>
|
||||
<SectionHeader title={heading} link={link} />
|
||||
{filterCategories.length > 0 && activeFilter && (
|
||||
<TabFilters
|
||||
categories={filterCategories}
|
||||
selectedFilter={activeFilter}
|
||||
onFilterSelect={setActiveFilter}
|
||||
/>
|
||||
)}
|
||||
<ul className={styles.cardsList}>
|
||||
{filteredCards.map((card, index) => (
|
||||
<li key={`${card.heading}-${index}`}>
|
||||
<ContentCard
|
||||
heading={card.heading}
|
||||
image={card.image}
|
||||
bodyText={card.bodyText}
|
||||
promoText={card.promoText}
|
||||
link={card.link}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Carousel className={styles.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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user