Skip to content

Commit c1269aa

Browse files
Add VideoPlayer components & function
1 parent d1bdcdf commit c1269aa

6 files changed

Lines changed: 54 additions & 5 deletions

File tree

src/App.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22
import Navbar from './components/Navbar/Navbar'
33
import Hero from './components/Hero/Hero'
44
import Programs from './components/Programs/Programs'
@@ -8,16 +8,19 @@ import Campus from './components/Campus/Campus'
88
import Testimonials from './components/Testimonials/Testimonials'
99
import Contact from './components/Contact/Contact'
1010
import Footer from './components/Footer/Footer'
11+
import VideoPlayer from './components/videoPlayer/VideoPlayer'
1112

1213
const App = () => {
14+
const [playState, setPlayState] = useState(false);
15+
1316
return (
1417
<div>
1518
<Navbar/>
1619
<Hero/>
1720
<div className="container">
1821
<Title subTitle='Our PROGRAM' title='What We Offer'/>
1922
<Programs/>
20-
<About/>
23+
<About setPlayState={setPlayState}/>
2124
<Title subTitle='Gallery' title='Campus Photos'/>
2225
<Campus/>
2326
<Title subTitle='TESTIMONIALS' title='What Student Says'/>
@@ -26,6 +29,7 @@ const App = () => {
2629
<Contact/>
2730
<Footer/>
2831
</div>
32+
<VideoPlayer playState={playState} setPlayState={setPlayState}/>
2933
</div>
3034
)
3135
}

src/assets/video.mp4

22.2 MB
Binary file not shown.

src/components/About/About.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
top: 50%;
2323
left: 50%;
2424
transform: translate(-50%,-50%);
25-
25+
cursor: pointer;
2626
}
2727
.about h3{
2828
font-weight: 600;

src/components/About/About.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import './About.css'
33
import about_img from '../../assets/about.png'
44
import play_icon from '../../assets/play-icon.png'
55

6-
const About = () => {
6+
const About = ({setPlayState}) => {
77
return (
88
<div className='about'>
99
<div className="about-left">
1010
<img src={about_img} className='about-img' alt="" />
11-
<img src={play_icon} className='play-icon' alt="" />
11+
<img src={play_icon} className='play-icon' onClick={()=>{
12+
setPlayState(true)
13+
}} alt="" />
1214
</div>
1315
<div className="about-right">
1416
<h3>ABOUT UNIVERSITY</h3>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.video-player{
2+
position: fixed;
3+
top: 0;
4+
left: 0;
5+
width: 100%;
6+
height: 100%;
7+
background: rgba(0,0,0,0.9);
8+
z-index: 100 ;
9+
display: flex;
10+
align-items: center;
11+
justify-content: center;
12+
}
13+
.video-player video{
14+
width: 90%;
15+
max-width: 900px;
16+
height: auto;
17+
border: 4px solid #fff;
18+
}
19+
20+
.hide{
21+
display: none;
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useRef } from 'react'
2+
import './VideoPlayer.css'
3+
import video from '../../assets/video.mp4'
4+
5+
const VideoPlayer = ({playState, setPlayState}) => {
6+
7+
const player = useRef(null);
8+
const closePlayer=(e)=>{
9+
if(e.target === player.current){
10+
setPlayState(false)
11+
}
12+
}
13+
14+
return (
15+
<div className={`video-player ${playState ? "" : "hide"}`} ref={player} onClick={closePlayer}>
16+
<video src={video} autoPlay muted controls></video>
17+
</div>
18+
)
19+
}
20+
21+
export default VideoPlayer

0 commit comments

Comments
 (0)