-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from aceleradora-TW/115/refactor-transformar-…
…o-carrosel-da-galeria-de-fotos-da-home-em-pagina 115/galeria de fotos da home em pagina
- Loading branch information
Showing
5 changed files
with
211 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { useEffect, useState } from "react" | ||
import NavBar from "../../components/navbar" | ||
import { GalleryStyled } from "./styled" | ||
import { cms } from "../../client" | ||
import { Swiper, SwiperSlide } from 'swiper/react' | ||
import { FreeMode, Navigation, Thumbs } from 'swiper/modules' | ||
|
||
import 'swiper/css' | ||
import 'swiper/css/free-mode' | ||
import 'swiper/css/navigation' | ||
import 'swiper/css/thumbs' | ||
|
||
export const GalleryDetails = () => { | ||
const [thumbsSwiper, setThumbsSwiper] = useState(null) | ||
const [gallery, setGallery] = useState([]) | ||
|
||
useEffect(() => { | ||
cms | ||
.get('api/gallery/?populate=fotos') | ||
.then((response) => { | ||
const images = response.data.data.attributes.fotos.data.map( | ||
(image, id) => { | ||
return { | ||
id, | ||
url: process.env.REACT_APP_URL_CMS + image.attributes.url | ||
} | ||
} | ||
) | ||
|
||
setGallery(images) | ||
}) | ||
.catch((error) => { | ||
throw new Error(error) | ||
}) | ||
}, []) | ||
return( | ||
<> | ||
<NavBar/> | ||
<GalleryStyled> | ||
<div className="container"> | ||
<div className="top"> | ||
<h2 className="h2-modal-galery">Fotos da Nossa Casa</h2> | ||
</div> | ||
<Swiper | ||
style={{ | ||
'--swiper-navigation-color': '#516B84', | ||
'--swiper-pagination-color': '#FFF', | ||
'--swiper-navigation-sides-offset': '10%', | ||
position: 'unset' | ||
}} | ||
loop={true} | ||
spaceBetween={10} | ||
navigation={true} | ||
thumbs={{ swiper: thumbsSwiper && !thumbsSwiper.destroyed ? thumbsSwiper : null }} | ||
modules={[FreeMode, Navigation, Thumbs]} | ||
className="first-carousel" | ||
> | ||
{gallery.map((fotos) => | ||
( | ||
<SwiperSlide key={fotos.id}> | ||
<img src={fotos.url} /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
<Swiper | ||
onSwiper={setThumbsSwiper} | ||
loop={true} | ||
spaceBetween={10} | ||
freeMode={true} | ||
watchSlidesProgress={true} | ||
modules={[FreeMode, Navigation, Thumbs]} | ||
className="second-carousel" | ||
breakpoints={{ | ||
320: {slidesPerView: 3}, | ||
520: {slidesPerView: 4}, | ||
700: {slidesPerView: 5}, | ||
1100: {slidesPerView: 6} | ||
}} | ||
> | ||
{gallery.map((image) => ( | ||
<SwiperSlide key={image.id}> | ||
<img src={image.url} /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
</div> | ||
</GalleryStyled> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import styled from "styled-components"; | ||
|
||
export const GalleryStyled = styled.div` | ||
*{ | ||
margin: 0; | ||
border: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
.container{ | ||
height: calc(100vh - 100px); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
align-items: center; | ||
.top { | ||
width: 100%; | ||
margin: 1% 0; | ||
} | ||
.top > .h2-modal-galery { | ||
font-size: 2.7rem; | ||
color: #54636E; | ||
text-align: center; | ||
} | ||
.swiper { | ||
width: 70%; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.first-carousel .swiper-slide { | ||
height: 70vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.second-carousel { | ||
margin-top: 1%; | ||
margin-bottom: 1%; | ||
} | ||
.second-carousel .swiper-slide { | ||
width: 90px; | ||
max-height: 90px; | ||
opacity: 0.5; | ||
} | ||
.second-carousel .swiper-slide-thumb-active { | ||
opacity: 1; | ||
border: 5px solid #f5bc4a; | ||
} | ||
.first-carousel img{ | ||
max-width: 100%; | ||
max-height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
.second-carousel img{ | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} | ||
@media (min-width: 320px) and (max-width: 767px) { | ||
.container { | ||
.top { | ||
padding: 2% 0; | ||
} | ||
.top > .h2-modal-galery { | ||
font-size: 1.9rem; | ||
} | ||
.swiper { | ||
width: 99%; | ||
} | ||
.first-carousel .swiper-slide { | ||
max-height: 100%; | ||
} | ||
.swiper-button-next, | ||
.swiper-button-prev { | ||
display: none; | ||
} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters