Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AvoCoreContentPickerType } from '@viaa/avo2-types';
import {
BLOCK_FIELD_DEFAULTS,
BLOCK_STATE_DEFAULTS,
Expand Down Expand Up @@ -115,6 +116,20 @@ export const IMAGE_CAROUSEL_CONFIG = (position = 0): ContentBlockConfig => ({
validator: undefined,
}),
...COPYRIGHT_FIELDS(),
imageAction: {
label: tText(
'modules/content-page/components/blocks/block-image-carousel/block-image-carousel___link'
),
editorType: ContentBlockEditor.ContentPicker,
editorProps: {
allowedTypes: [
AvoCoreContentPickerType.EXTERNAL_LINK,
AvoCoreContentPickerType.CONTENT_PAGE,
AvoCoreContentPickerType.IE_OBJECT,
],
hideTargetSwitch: true,
},
},
},
type: 'fieldGroup',
repeat: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@use "../../../../shared/styles/settings/variables" as variables;
@use "../../../../shared/styles/settings/colors" as colors;
@use "../../../../shared/styles/mixins/typography" as typography;
@use "../../../../shared/styles/mixins/animations" as animations;

.c-block-image-carousel {
.c-block-image-carousel__header {
Expand Down Expand Up @@ -83,6 +84,14 @@
object-fit: contain;
object-position: center;
}

&--link > img {
@include animations.zoom-in-transition;

&:hover {
@include animations.zoom-in-animation;
}
}
}

// Compound selector (both classes are on the same element, see BlockImageCarousel.tsx):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import type {
import type { DefaultComponentProps } from '~modules/shared/types/components';

import './BlockImageCarousel.scss';
import type { ButtonAction } from '@viaa/avo2-components';

export interface BlockImageCarouselProps extends DefaultComponentProps {
title: string;
titleType: HeadingTypeOption;
elements: ({
image: string;
imageAlt: string;
imageAction?: ButtonAction;
} & CopyrightComponentState)[];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import { Image } from '@viaa/avo2-components';
import { type ButtonAction, Image } from '@viaa/avo2-components';
import clsx from 'clsx';
import React, {
type CSSProperties,
type FunctionComponent,
type ReactElement,
useEffect,
useRef,
useState,
} from 'react';
import { useSwiper } from 'swiper/react';
import type { CopyrightComponentState } from '~modules/content-page/types/content-block.types';
import { CopyrightAttribution } from '~shared/components/CopyrightAttribution';
import { generateSmartLink } from '~shared/components/SmartLink/SmartLink.tsx';

import './BlockImageCarousel.scss';

export interface ImageCarouselSlideProps extends CopyrightComponentState {
title: string;
image: string;
imageAlt: string;
imageAction?: ButtonAction;
}

export const ImageCarouselSlide: FunctionComponent<ImageCarouselSlideProps> = ({
title,
image,
imageAlt,
imageAction,
copyrightTitle,
copyrightText,
copyrightIconVisible,
}): ReactElement => {
const imageWrapperRef = useRef<HTMLDivElement>(null);
const [imageWrapperRef, setImageWrapperRef] = useState<HTMLDivElement | null>(null);
const [imageWidth, setImageWidth] = useState<number | undefined>(undefined);
const swiper = useSwiper();

useEffect(() => {
const imageEl = imageWrapperRef.current?.querySelector('img');
const imageEl = imageWrapperRef?.querySelector('img');
if (!imageEl) {
return;
}
Expand All @@ -54,7 +56,7 @@ export const ImageCarouselSlide: FunctionComponent<ImageCarouselSlideProps> = ({
resizeObserver.observe(imageEl);

return () => resizeObserver.disconnect();
}, [swiper]);
}, [swiper, imageWrapperRef]);

return (
<div
Expand All @@ -67,14 +69,20 @@ export const ImageCarouselSlide: FunctionComponent<ImageCarouselSlideProps> = ({
} as CSSProperties)
}
>
<div ref={imageWrapperRef} className="c-block-image-carousel__slide-image-wrapper">
<Image
src={image}
alt={imageAlt || title}
className={clsx('c-block-image-carousel__slide-image')}
loading="lazy"
/>
</div>
{generateSmartLink(
imageAction,
<div ref={setImageWrapperRef} className="c-block-image-carousel__slide-image-wrapper">
<Image
src={image}
alt={imageAlt || title}
className={clsx('c-block-image-carousel__slide-image', {
'c-block-image-carousel__slide-image--link': !!imageAction,
Comment thread
reunefe marked this conversation as resolved.
})}
loading="lazy"
/>
</div>,
imageAlt || title
)}
{imageWidth !== undefined && (
<CopyrightAttribution
className="c-block-image-carousel__slide-image-attribution"
Expand Down