forked from donaldboulton/gatsby-starter-dimension-v4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
165 additions
and
46 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
.embedded-video { | ||
margin-bottom: 3rem; | ||
} | ||
|
||
.image-gallery { | ||
position: relative; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.image-paginator { | ||
@include vendor('display', 'flex'); | ||
@include vendor('align-items', 'center'); | ||
@include vendor('justify-content', 'center'); | ||
gap: 0.5rem; | ||
color: white; | ||
} | ||
|
||
.paginator-icon { | ||
cursor: pointer; | ||
opacity: 1; | ||
font-size: 1.75rem; | ||
} | ||
|
||
.disabled-paginator-icon { | ||
cursor: default; | ||
opacity: 0.5; | ||
font-size: 1.75rem; | ||
} | ||
|
||
.page-indicator { | ||
user-select: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,7 @@ | |
@import 'layout/header'; | ||
@import 'layout/main'; | ||
@import 'layout/footer'; | ||
|
||
// Cards. | ||
|
||
@import "cards/proposal"; |
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 |
---|---|---|
@@ -1,32 +1,72 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { StaticImage } from 'gatsby-plugin-image'; | ||
import Card from '@/components/Card'; | ||
import Video from '@/components/Video'; | ||
import { StaticImage } from 'gatsby-plugin-image'; | ||
import { RiArrowLeftSLine, RiArrowRightSLine } from 'react-icons/ri'; | ||
import { useSwipeable } from 'react-swipeable'; | ||
|
||
const Proposal = props => { | ||
const [currentPage, setCurrentPage] = useState(1); | ||
const totalPages = 3; | ||
|
||
const prevPage = () => { | ||
setCurrentPage(currentPage => Math.max(1, currentPage - 1)); | ||
}; | ||
|
||
const nextPage = () => { | ||
setCurrentPage(currentPage => Math.min(totalPages, currentPage + 1)); | ||
}; | ||
|
||
const handlers = useSwipeable({ | ||
onSwipedLeft: () => nextPage(), | ||
onSwipedRight: () => prevPage(), | ||
preventScrollOnSwipe: true, | ||
trackMouse: false, | ||
trackTouch: true, | ||
}); | ||
|
||
const Proposal = (props) => ( | ||
<Card id="Proposal" style={props.style} onCloseArticle={props.onCloseArticle} articleClassName={props.articleClassName}> | ||
<h2 className="major">Lánykérés</h2> | ||
<span className="image main"> | ||
<StaticImage formats={['auto', 'webp']} src="../../static/assets/pic02.jpg" alt="Proposal" /> | ||
</span> | ||
<p> | ||
Adipiscing magna sed dolor elit. Praesent eleifend dignissim arcu, at eleifend sapien imperdiet ac. Aliquam | ||
erat volutpat. Praesent urna nisi, fringila lorem et vehicula lacinia quam. Integer sollicitudin mauris nec | ||
lorem luctus ultrices. | ||
</p> | ||
<p> | ||
Nullam et orci eu lorem consequat tincidunt vivamus et sagittis libero. Mauris aliquet magna magna sed nunc | ||
rhoncus pharetra. Pellentesque condimentum sem. In efficitur ligula tate urna. Maecenas laoreet massa vel | ||
lacinia pellentesque lorem ipsum dolor. Nullam et orci eu lorem consequat tincidunt. Vivamus et sagittis | ||
libero. Mauris aliquet magna magna sed nunc rhoncus amet feugiat tempus. | ||
</p> | ||
</Card> | ||
); | ||
const renderCurrentImage = () => { | ||
switch ( currentPage ) { | ||
case 1: | ||
return <StaticImage formats={['auto', 'webp']} src="../../static/assets/pic01.jpg" alt="Proposal" />; | ||
case 2: | ||
return <StaticImage formats={['auto', 'webp']} src="../../static/assets/pic02.jpg" alt="Proposal" />; | ||
case 3: | ||
return <StaticImage formats={['auto', 'webp']} src="../../static/assets/pic03.jpg" alt="Proposal" />; | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<Card id="Proposal" style={props.style} onCloseArticle={props.onCloseArticle} articleClassName={props.articleClassName}> | ||
<h2 className="major">Lánykérés</h2> | ||
|
||
<div className="embedded-video" style={{ marginBottom: '2rem' }}> | ||
{/*{props.isVideoVisible && <Video videoSrcURL="" videoTitle="Lánykérés 2023" />}*/} | ||
</div> | ||
|
||
<div {...handlers} className="image-gallery" style={{ marginBottom: '1rem' }}> | ||
{renderCurrentImage()} | ||
</div> | ||
|
||
<div className="image-paginator"> | ||
<RiArrowLeftSLine className={currentPage === 1 ? 'disabled-paginator-icon' : 'paginator-icon'} | ||
onClick={currentPage === 1 ? undefined : prevPage} /> | ||
<span className="page-indicator">{currentPage} / {totalPages}</span> | ||
<RiArrowRightSLine className={currentPage === totalPages ? 'disabled-paginator-icon' : 'paginator-icon'} | ||
onClick={currentPage === totalPages ? undefined : nextPage} /> | ||
</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
Proposal.propTypes = { | ||
articleClassName: PropTypes.string.isRequired, | ||
style: PropTypes.any.isRequired, | ||
onCloseArticle: PropTypes.func.isRequired, | ||
isVideoVisible: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export default Proposal; |
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,27 @@ | ||
import React from 'react'; | ||
|
||
const Video = ({ videoSrcURL, videoTitle, ...props }) => ( | ||
<div className="video" style={{ | ||
position: 'relative', | ||
paddingBottom: '56.25%' /* 16:9 */, | ||
paddingTop: 25, | ||
height: 0, | ||
}}> | ||
<iframe | ||
src={videoSrcURL} | ||
title={videoTitle} | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
frameBorder="0" | ||
webkitallowfullscreen="true" | ||
mozallowfullscreen="true" | ||
allowFullScreen | ||
style={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
}} /> | ||
</div> | ||
); | ||
export default Video; |
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