Skip to content

Commit 89a3738

Browse files
committed
full version
1 parent b2c18a5 commit 89a3738

11 files changed

+158
-35
lines changed

LICENSE.MD

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 Stephen Grider
3+
Copyright (c) 2018 Lingyun Zhao
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -12,10 +12,3 @@ furnished to do so, subject to the following conditions:
1212
The above copyright notice and this permission notice shall be included in all
1313
copies or substantial portions of the Software.
1414

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# ReduxSimpleStarter
22

3-
Interested in learning [Redux](https://www.udemy.com/react-redux/)?
4-
53
### Getting Started
64

75
There are two methods for getting started with this repo.

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"react-dom": "^0.14.3",
3333
"react-redux": "4.3.0",
3434
"react-router": "^2.0.1",
35-
"redux": "^3.0.4"
35+
"redux": "^3.0.4",
36+
"youtube-api-search": "0.0.5"
3637
}
3738
}

src/components/app.js

-9
This file was deleted.

src/components/search_bar.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, {Component} from 'react';
2+
3+
class SearchBar extends Component {
4+
5+
constructor(props){
6+
7+
super(props);
8+
9+
this.state = {term: ''};
10+
}
11+
12+
render(){
13+
14+
return (
15+
<div className="search-bar">
16+
<input
17+
value = {this.state.term}
18+
onChange={event => this.onInputChange(event.target.value)}/>
19+
</div>
20+
);
21+
}
22+
23+
onInputChange(term){
24+
this.setState({term});
25+
this.props.onSearchTermChange(term);
26+
27+
}
28+
}
29+
30+
export default SearchBar;

src/components/video_detail.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
const VideoDetail = ({video}) =>{
4+
if(!video){
5+
6+
return <div>Loading...</div>;
7+
}
8+
9+
const videoId = video.id.videoId;
10+
const url = `https://www.youtube.com/embed/${videoId}`;
11+
12+
return(
13+
<div className= "video-detail col-md-8">
14+
<div className="embed-responsive embed-responsive-16by9">
15+
<iframe className="embed-responsive-item" src={url}></iframe>
16+
</div>
17+
<div className="details">
18+
<div>{video.snippet.title}</div>
19+
<div>{video.snippet.description}</div>
20+
</div>
21+
</div>
22+
);
23+
};
24+
25+
export default VideoDetail;

src/components/video_list.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, {Component} from 'react';
2+
import VideoListItem from './video_list_item';
3+
4+
class VideoList extends Component{
5+
6+
constructor(props){
7+
8+
super(props);
9+
10+
this.state = {term: 'search'};
11+
}
12+
13+
14+
15+
render(){
16+
const videoItems = this.props.videos.map((video)=>{
17+
return (
18+
<VideoListItem
19+
onVideoSelect= {this.props.onVideoSelect}
20+
key={video.etag}
21+
video={video} />
22+
23+
);
24+
});
25+
26+
return(
27+
28+
<ul className = "col-md-4 list-group">
29+
{videoItems}
30+
</ul>
31+
32+
);
33+
}
34+
}
35+
36+
export default VideoList;

src/components/video_list_item.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, {Component} from 'react';
2+
3+
const VideoListItem = ({video, onVideoSelect}) =>{
4+
//const video = props.video;
5+
const imgUrl = video.snippet.thumbnails.default.url;
6+
return(
7+
<li onClick={()=> onVideoSelect(video)} className = 'list-group-item'>
8+
<div className = "video-list media">
9+
<div className = "media-left">
10+
<img className = "media-object" src={imgUrl} />
11+
</div>
12+
<div className="media-body">
13+
<div className="media-heading">{video.snippet.title} </div>
14+
</div>
15+
</div>
16+
17+
</li>
18+
19+
);
20+
}
21+
22+
export default VideoListItem;

src/index.js

+1-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

style/style.css

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.search-bar{
2+
margin: 20px;
3+
text-align: center;
4+
}
5+
6+
.search-bar input{
7+
width: 75%;
8+
}
9+
10+
.video-item img{
11+
max-width: 64px;
12+
}
13+
14+
.video-detail .details{
15+
margin-top: 10px;
16+
padding: 10px;
17+
border: 1px solid #ddd
18+
border-radius: 4px;
19+
}
20+
21+
.list-group-item{
22+
cursor: pointer;
23+
}
24+
25+
.list-group-item:hover{
26+
27+
background-color: #eee;
28+
}

0 commit comments

Comments
 (0)