Added basic carousel to gallery page
This commit is contained in:
parent
8cbb19ee78
commit
ef7cfccab8
3 changed files with 51 additions and 29 deletions
|
|
@ -89,7 +89,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.show_block{
|
.show_block{
|
||||||
*display: inline;
|
display: inline;
|
||||||
zoom: 1;
|
zoom: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
|
@ -307,3 +307,11 @@
|
||||||
table td {
|
table td {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.carousel {
|
||||||
|
height: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel-item {
|
||||||
|
display: block
|
||||||
|
}
|
||||||
|
|
@ -1,32 +1,44 @@
|
||||||
import Image from "next/legacy/image";
|
import Image from "next/legacy/image";
|
||||||
import { Navigation, Pagination, Scrollbar, A11y, Autoplay } from 'swiper';
|
import { Navigation, Pagination, Scrollbar, A11y, Autoplay } from 'swiper';
|
||||||
import { Swiper, SwiperSlide } from 'swiper/react';
|
import { Carousel, CarouselItem } from "react-bootstrap";
|
||||||
import 'swiper/css';
|
import { useState } from "react";
|
||||||
import 'swiper/css/navigation';
|
import Link from 'next/link'
|
||||||
import 'swiper/css/pagination';
|
|
||||||
import 'swiper/css/scrollbar';
|
const GalleryCarousel = ({galleryImages, basepath, gallery}) => {
|
||||||
|
const bootstrap = galleryImages.data;
|
||||||
|
const [index, setIndex] = useState(0);
|
||||||
|
|
||||||
|
console.log(bootstrap)
|
||||||
|
|
||||||
|
const handleSelect = (selectedIndex, e) => {
|
||||||
|
setIndex(selectedIndex);
|
||||||
|
};
|
||||||
|
|
||||||
const GalleryCarousel = ({galleryImages, basepath}) => {
|
|
||||||
console.log(galleryImages.data[0])
|
|
||||||
return(
|
return(
|
||||||
<Swiper
|
<Carousel activeIndex={index} onSelect={handleSelect} fade>
|
||||||
modules={[Navigation, Pagination, Scrollbar, A11y, Autoplay]}
|
{bootstrap.map((item =>
|
||||||
spaceBetween={50}
|
<Carousel.Item key={item.id} interval={4000}>
|
||||||
slidesPerView={1}
|
<Link href={"/gallery/" + gallery.attributes.Slug + "/" + item.attributes.Slug}><Image
|
||||||
onSlideChange={() => console.log('slide change')}
|
src={basepath + item.attributes.Image.data.attributes.formats.large.url}
|
||||||
onSwiper={(swiper) => console.log(swiper)}
|
style={{
|
||||||
scrollbar={{ draggable: true }}
|
width: '100%',
|
||||||
>
|
height: 'auto',
|
||||||
{galleryImages.data.map(item => (
|
}}
|
||||||
<SwiperSlide
|
height={item.attributes.Image.data.attributes.formats.large.height}
|
||||||
key={item.attributes.Title}
|
width={item.attributes.Image.data.attributes.formats.large.width}
|
||||||
>
|
key={item.attributes.id}
|
||||||
<img
|
//className="card-img-top"
|
||||||
src={basepath + item.attributes.Image.data.attributes.formats.medium.url}
|
alt={item.attributes.Title}
|
||||||
alt={item.attributes.Title}></img>
|
></Image></Link>
|
||||||
</SwiperSlide>
|
<Carousel.Caption >
|
||||||
))}
|
<h3>{item.title}</h3>
|
||||||
</Swiper>
|
<p>{item.body}</p>
|
||||||
|
</Carousel.Caption>
|
||||||
|
</Carousel.Item>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
|
||||||
|
</Carousel>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { getGallery, getGalleryImages } from "../../data/external/cms.js"
|
||||||
import GalleryPager from "../../components/gallerypager.js"
|
import GalleryPager from "../../components/gallerypager.js"
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import config from "../../data/internal/config.js"
|
import config from "../../data/internal/config.js"
|
||||||
|
import GalleryCarousel from "../../components/gallerycarousel.js"
|
||||||
|
|
||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
|
|
||||||
|
|
@ -47,6 +48,7 @@ const Gallery = ({pagedata, gallery, galleryImages, serverRuntimeConfig, og_imag
|
||||||
<meta name="og:description" content={ gallery.attributes.Description } key="description"></meta>
|
<meta name="og:description" content={ gallery.attributes.Description } key="description"></meta>
|
||||||
</Head>
|
</Head>
|
||||||
<h1 className="page_title col-sm-12">{gallery.attributes.Title}</h1>
|
<h1 className="page_title col-sm-12">{gallery.attributes.Title}</h1>
|
||||||
|
<GalleryCarousel galleryImages={galleryImages} basepath={serverRuntimeConfig.media_path} gallery={gallery}></GalleryCarousel>
|
||||||
<GalleryPager galleryImages={galleryImages} basepath={serverRuntimeConfig.media_path} gallery={gallery}></GalleryPager>
|
<GalleryPager galleryImages={galleryImages} basepath={serverRuntimeConfig.media_path} gallery={gallery}></GalleryPager>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue