-
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
Cnaresh02
authored and
Cnaresh02
committed
Nov 29, 2022
0 parents
commit f1a4e89
Showing
17 changed files
with
10,409 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,3 @@ | ||
node_modules | ||
package-lock.json | ||
node_modules |
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,67 @@ | ||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm init` | ||
|
||
Runs the app in the development mode.<br> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.<br> | ||
You will also see any lint errors in the console. | ||
|
||
### `npm start` | ||
|
||
Which will run the app (make sure to enter your youtube api key in the code) | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.<br> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.<br> | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
### Code Splitting | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting | ||
|
||
### Analyzing the Bundle Size | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size | ||
|
||
### Making a Progressive Web App | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app | ||
|
||
### Advanced Configuration | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration | ||
|
||
### Deployment | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment | ||
|
||
### `npm run build` fails to minify | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify |
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,30 @@ | ||
{ | ||
"name": "videos", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"axios": "^0.18.0", | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
"react-scripts": "2.1.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts --openssl-legacy-provider start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": "react-app" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
], | ||
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).", | ||
"main": "index.js", | ||
"author": "Naresh C", | ||
"license": "ISC" | ||
} |
Binary file not shown.
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,42 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>Youtube React App</title> | ||
</head> | ||
<body style="background-color: rgb(243, 240, 240);"> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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,15 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
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,11 @@ | ||
import axios from 'axios'; | ||
const KEY = '<API KEY: YOUTUBE API V3>'; // mention your youtube API key here | ||
|
||
export default axios.create({ | ||
baseURL: 'https://www.googleapis.com/youtube/v3/', | ||
params: { | ||
part: 'snippet', | ||
maxResults: 5, | ||
key: KEY | ||
} | ||
}) |
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,47 @@ | ||
import React from 'react'; | ||
import SearchBar from './Searchbar'; | ||
import youtube from '../apis/youtube'; | ||
import VideoList from './VideoList'; | ||
import VideoDetail from './VideoDetail'; | ||
|
||
class App extends React.Component { | ||
state = { | ||
videos: [], | ||
selectedVideo: null | ||
} | ||
handleSubmit = async (termFromSearchBar) => { | ||
const response = await youtube.get('/search', { | ||
params: { | ||
q: termFromSearchBar | ||
} | ||
}) | ||
|
||
this.setState({ | ||
videos: response.data.items | ||
}) | ||
console.log("this is resp",response); | ||
}; | ||
handleVideoSelect = (video) => { | ||
this.setState({selectedVideo: video}) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className='ui container' style={{marginTop: '1em'}}> | ||
<SearchBar handleFormSubmit={this.handleSubmit}/> | ||
<div className='ui grid'> | ||
<div className="ui row"> | ||
<div className="eleven wide column"> | ||
<VideoDetail video={this.state.selectedVideo}/> | ||
</div> | ||
<div className="five wide column"> | ||
<VideoList handleVideoSelect={this.handleVideoSelect} videos={this.state.videos}/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default App; |
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 @@ | ||
import React from 'react'; | ||
|
||
class Searchbar extends React.Component { | ||
handleChange = (event) => { | ||
this.setState({ | ||
term: event.target.value | ||
}); | ||
|
||
}; | ||
handleSubmit = event => { | ||
event.preventDefault(); | ||
this.props.handleFormSubmit(this.state.term); | ||
} | ||
|
||
render() { | ||
|
||
return ( | ||
<> | ||
<h2 style={{textAlign:"center"}}><img style={{width:'200px', height:'100px',justifyContent:'center'}} src='https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/YouTube_Logo_%282013-2017%29.svg/2560px-YouTube_Logo_%282013-2017%29.svg.png' alt="youtube logo"></img></h2> | ||
<div className='search-bar ui segment'> | ||
<form onSubmit={this.handleSubmit} className='ui form'> | ||
<div className='field'> | ||
<label htmlFor="video-search">Video Search</label> | ||
<input onChange={this.handleChange} name='video-search' type="text" placeholder="Search.."/> | ||
</div> | ||
</form> | ||
</div> | ||
</> | ||
) | ||
} | ||
} | ||
export default Searchbar; |
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 @@ | ||
import React from "react"; | ||
|
||
const VideoDetail = ({ video }) => { | ||
if (!video) { | ||
return <div> | ||
<h1>Enter search keyword to load...</h1> | ||
<br></br> | ||
<p style={{fontSize:'25px'}}> | ||
Use the API to search for videos matching specific search terms, topics, locations, publication dates, and much more. The APIs search.list method also supports searches for playlists and channels. | ||
|
||
With the YouTube Data API, you can add a variety of YouTube features to your application. Use the API to upload videos, manage playlists and subscriptions, update channel settings, and more. | ||
|
||
</p> | ||
</div>; | ||
} | ||
|
||
const videoSrc = `https://www.youtube.com/embed/${video.id.videoId}`; | ||
console.log(typeof video); | ||
return ( | ||
<div> | ||
<div className="ui embed"> | ||
<iframe src={videoSrc} allowFullScreen title="Video player" /> | ||
</div> | ||
<div className="ui segment"> | ||
<h4 className="ui header">{video.snippet.title}</h4> | ||
<p>{video.snippet.description}</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default VideoDetail; |
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,14 @@ | ||
import React from 'react'; | ||
import '../style/video.css'; | ||
|
||
const VideoItem = ({video , handleVideoSelect}) => { | ||
return ( | ||
<div onClick={ () => handleVideoSelect(video)} className=' video-item item'> | ||
<img className='ui image' src={video.snippet.thumbnails.medium.url} alt={video.snippet.description}/> | ||
<div className='content'> | ||
<div className='header '>{video.snippet.title}</div> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
export default VideoItem; |
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,12 @@ | ||
import React from 'react'; | ||
import VideoItem from './VideoItem'; | ||
|
||
const VideoList = ({videos , handleVideoSelect}) => { | ||
const renderedVideos = videos.map((video) => { | ||
return <VideoItem key={video.id.videoId} video={video} handleVideoSelect={handleVideoSelect} /> | ||
// console.log(video.id); | ||
}); | ||
|
||
return <div className='ui relaxed divided list'>{renderedVideos}</div>; | ||
}; | ||
export default VideoList; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
import React from 'react' ; | ||
import ReactDOM from 'react-dom'; | ||
import App from './components/App'; | ||
|
||
|
||
ReactDOM.render( | ||
<App />, document.querySelector('#root')); | ||
|
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,10 @@ | ||
.video-item { | ||
display: flex !important; | ||
align-items: center !important; | ||
cursor: pointer; | ||
} | ||
|
||
.video-item.item img { | ||
max-width: 200px; | ||
max-height: 250px ; | ||
} |
Oops, something went wrong.