I am working on Sitecore 10.3
with headless Next.js
. I want carousel component
in next js with scroll this is my NextJs
component code. Is there any way with the help I can use JS in this code for scrolling
.
import { TextField, RichTextField, ImageField,RichText } from "@sitecore-jss/sitecore-jss-nextjs";
type FieldsCarouselDetailsFieldsFields = {
Title?: TextField;
Description?: RichTextField;
Image?: ImageField;
};
type FieldsCarouselDetailsFields = {
id?: string;
url?: string;
name?: string;
displayName?: string;
fields?: FieldsCarouselDetailsFieldsFields;
};
type Fields = {
CarouselDetails?: FieldsCarouselDetailsFields[];
};
const baseurl = "https://www.dockerlearning.localhost";
type CarouselDetailsProps = {
fields?: Fields;
};
const CarouselDetails = (props: CarouselDetailsProps): JSX.Element => (
<div id="carouselExampleIndicators" className="carousel slide" data-ride="carousel">
<ol className="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" className="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div className="carousel-inner">
{
props.fields?.CarouselDetails?.map(item => {
return (
<div>
<div className="carousel-item active">
<img className="d-block w-100" src= {baseurl+item.fields?.Image?.value?.src} alt="First slide" style={{ height: '777px' , width: '777px' }}/>
</div>
<div className="carousel-caption d-none d-md-block">
<h5>{item.fields?.Title?.value}</h5>
<RichText field={item.fields?.Description}></RichText>
</div>
</div>
)
})
}
</div>
<a className="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span className="carousel-control-prev-icon" aria-hidden="true"></span>
<span className="sr-only">Previous</span>
</a>
<a className="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span className="carousel-control-next-icon" aria-hidden="true"></span>
<span className="sr-only">Next</span>
</a>
</div>
);
export default CarouselDetails;