import { Field, ImageField, NextImage as JssImage, Link as JssLink, LinkField, Text, useSitecoreContext, } from '@sitecore-content-sdk/nextjs'; import React, { CSSProperties, JSX } from 'react'; interface Fields { Image: ImageField & { metadata?: { [key: string]: unknown } }; ImageCaption: Field; TargetUrl: LinkField; } type ImageProps = { params: { [key: string]: string }; fields: Fields; }; const ImageDefault = (props: ImageProps): JSX.Element => (
Image
); export const Banner = (props: ImageProps): JSX.Element => { const id = props.params.RenderingIdentifier; const { sitecoreContext } = useSitecoreContext(); const isPageEditing = sitecoreContext.pageEditing; const classHeroBannerEmpty = isPageEditing && props.fields?.Image?.value?.class === 'scEmptyImage' ? 'hero-banner-empty' : ''; const backgroundStyle = (props?.fields?.Image?.value?.src && { backgroundImage: `url('${props.fields.Image.value.src}')`, }) as CSSProperties; const modifyImageProps = { ...props.fields.Image, value: { ...props.fields.Image.value, style: { width: '100%', height: '100%' }, }, }; return (
{sitecoreContext.pageEditing ? : ''}
); }; export const Default = (props: ImageProps): JSX.Element => { const { sitecoreContext } = useSitecoreContext(); if (props.fields) { const Image = () => ; const id = props.params.RenderingIdentifier; return (
{sitecoreContext.pageState === 'edit' || !props.fields.TargetUrl?.value?.href ? ( ) : ( )}
); } return ; };