-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make SimpleCarousel not so simple (#35)
* Make SimpleCarousel not so simple * Fix TS error
- Loading branch information
Showing
17 changed files
with
461 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 24 additions & 3 deletions
27
apps/sanity/src/contentSections/carousels/SimpleCarousel/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,48 @@ | ||
import { stegaClean } from "@sanity/client/stega"; | ||
import EmptyBlock from "@shared/ui/components/EmptyBlock"; | ||
|
||
import { SimpleCarousel as SimpleCarouselUI } from "@shared/ui"; | ||
|
||
import { prepareImageProps } from "@/lib/adapters/prepareImageProps"; | ||
import { prepareRichTextProps } from "@/lib/adapters/prepareRichTextProps"; | ||
import SectionContainer from "@/components/SectionContainer"; | ||
|
||
import type { ISimpleCarouselProps } from "./types"; | ||
|
||
export default function SimpleCarousel({ data }: ISimpleCarouselProps) { | ||
if (!data) return null; | ||
|
||
const { slides } = data; | ||
const { text, slides, fullWidth, params } = data; | ||
const effect = stegaClean(data.effect); | ||
const { loop, slidesPerView, spaceBetween } = params || {}; | ||
|
||
if (!slides || slides.length === 0) | ||
return <EmptyBlock name="Simple Carousel" />; | ||
|
||
const carouselSlides = slides.map((slide) => ({ | ||
image: prepareImageProps(slide.image), | ||
text: prepareRichTextProps(slide.text), | ||
effect, | ||
})); | ||
|
||
return ( | ||
<SectionContainer sectionData={data}> | ||
<SimpleCarouselUI slides={carouselSlides} /> | ||
<SectionContainer | ||
sectionData={{ | ||
...data, | ||
paddingX: "none", | ||
noMaxWidth: fullWidth, | ||
}} | ||
> | ||
<SimpleCarouselUI | ||
text={prepareRichTextProps(text)} | ||
slides={carouselSlides} | ||
effect={effect} | ||
params={{ | ||
loop, | ||
slidesPerView: slidesPerView || (effect === "cards" ? 1 : 3), | ||
spaceBetween: spaceBetween || 20, | ||
}} | ||
/> | ||
</SectionContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.