Merged in feat/SW-1521-image-gallery-lightbox (pull request #1226)
Feat/SW-1521 image gallery lightbox * feat(SW-1453): added city listing component * feat(SW-1521): added more generic types to ImageGallery and Lightbox components * feat(SW-1521): added lightbox functionality for top images * feat(SW-1521): added support for setting activeIndex on open inside Lightbox Approved-by: Fredrik Thorsson Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
34
utils/imageGallery.ts
Normal file
34
utils/imageGallery.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { GalleryImage } from "@/types/components/imageGallery"
|
||||
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
||||
import type { ApiImage } from "@/types/hotel"
|
||||
|
||||
function mapApiImageToGalleryImage(apiImage: ApiImage): GalleryImage {
|
||||
return {
|
||||
src: apiImage.imageSizes.medium,
|
||||
alt: apiImage.metaData.altText || apiImage.metaData.title,
|
||||
caption: apiImage.metaData.title,
|
||||
smallSrc: apiImage.imageSizes.small,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapApiImagesToGalleryImages(
|
||||
apiImages: ApiImage[]
|
||||
): GalleryImage[] {
|
||||
return apiImages.map(mapApiImageToGalleryImage)
|
||||
}
|
||||
|
||||
function mapImageVaultImageToGalleryImage(
|
||||
imageVaultImage: ImageVaultAsset
|
||||
): GalleryImage {
|
||||
return {
|
||||
src: imageVaultImage.url,
|
||||
alt: imageVaultImage.meta.alt || imageVaultImage.meta.caption || "",
|
||||
caption: imageVaultImage.meta.caption,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapImageVaultImagesToGalleryImages(
|
||||
imageVaultImages: ImageVaultAsset[]
|
||||
): GalleryImage[] {
|
||||
return imageVaultImages.map(mapImageVaultImageToGalleryImage)
|
||||
}
|
||||
Reference in New Issue
Block a user