import React from "react"; import { Image as JssImage, Link as JssLink, ImageField, Field, LinkField, Text, useSitecoreContext, } from "@sitecore-jss/sitecore-jss-nextjs"; interface Fields { Image: ImageField; 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 { sitecoreContext } = useSitecoreContext(); const backgroundStyle = { backgroundImage: `url('${props?.fields?.Image?.value?.src}')`, }; const modifyImageProps = { ...props.fields.Image, editable: props?.fields?.Image?.editable ?.replace(`width="${props?.fields?.Image?.value?.width}"`, 'width="100%"') .replace( `height="${props?.fields?.Image?.value?.height}"`, 'height="100%"', ), }; const id = props.params.RenderingIdentifier; 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" ? ( ) : ( )}
); } return ; };