Skip to content

Commit

Permalink
added close button to video pop up, updated watch now button, updated…
Browse files Browse the repository at this point in the history
… css styling for home page for close btn
  • Loading branch information
alvarotorrestx committed Aug 16, 2023
1 parent 285ef30 commit ece2916
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/pages/home/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
height: 0;
}

.responsive-video .btn-close {
width: 1.5em;
height: 1.5em;
background-size: contain;
}

/* media queries */
@media screen and (max-width: 600px) {
.home {
Expand Down Expand Up @@ -205,5 +211,11 @@
margin-left: 10px;
padding-bottom: 10px;
height: 1%;
flex-direction: column-reverse;
}

.responsive-video .btn-close {
margin: 1em 0;
width: 100%;
}
}
26 changes: 21 additions & 5 deletions src/pages/home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ const Index = ({ handleWatchVideo, clicked }) => {
</button>
</Link>
<button
id='watchBtn'
className="booking-button"
type="click"
onClick={handleWatchVideo}
src="https://www.youtube.com/watch?v=Gg4wtsWgw5k"
>
Watch Video
{clicked ? "Close Video" : "Watch Video"}
</button>
{clicked && (
{clicked ? (
<div className="responsive-video">
<ReactPlayer url="https://www.youtube.com/watch?v=Gg4wtsWgw5k" controls={true} playsinline={true}/>
<ReactPlayer url="https://www.youtube.com/watch?v=Gg4wtsWgw5k" controls={true} playsinline={true} />
<button type="button" className="btn-close mx-2" aria-label="Close" onClick={handleWatchVideo}></button>
</div>
)}
) :
<div className="responsive-video">

</div>
}
</div>

<div className="details">
Expand All @@ -65,7 +71,17 @@ export default function Home() {
// handle watch video
const [clicked, isClicked] = useState(false);

const handleWatchVideo = () => isClicked(true);
const handleWatchVideo = () => isClicked(prevValue => !prevValue);

const responsiveVideoDiv = document.querySelector('.responsive-video')
const watchBtn = document.querySelector('#watchBtn')
document.addEventListener('click', e => {
if (clicked && e.target !== watchBtn) {
if (e.target !== responsiveVideoDiv) {
isClicked(false)
}
}
})

return (
<div>
Expand Down

0 comments on commit ece2916

Please sign in to comment.