Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35,710 changes: 35,710 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^12.1.3",
"axios": "^0.21.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^4.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
"react-scripts": "3.4.3",
"styled-components": "^5.2.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
12 changes: 12 additions & 0 deletions src/apis/youtube.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import axios from 'axios';

const KEY = 'AIzaSyAKlMA9FgSpXSkjxhs69n6zsBOPhcHtiKA';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I highly recommend hiding this key on .env file


export default axios.create({
baseURL: 'https://www.googleapis.com/youtube/v3',
params: {
part: 'snippet',
maxResults: 5,
key: KEY,
},
});
58 changes: 0 additions & 58 deletions src/components/App/App.component.jsx

This file was deleted.

36 changes: 36 additions & 0 deletions src/components/App/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useState, useEffect } from 'react';
import NavBar from '../NavBar';
import HomePage from '../../pages/Home';
import youtube from '../../apis/youtube';

function App() {
const [search, setSearch] = useState('Wizeline');
const [videos, setVideos] = useState([]);

const handleSearch = (e) => {
setSearch(e.target.value);
console.log(search);
};

useEffect(() => {
async function fetchData() {
const response = await youtube.get('/search', {
params: {
q: search,
},
});
console.log(response.data.items);
setVideos(response.data.items);
}
fetchData();
}, [search]);
console.log(videos);
return (
<div>
<NavBar search={handleSearch} />
<HomePage videos={videos} />
</div>
);
}

export default App;
2 changes: 1 addition & 1 deletion src/components/App/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './App.component';
export { default } from './App';
12 changes: 0 additions & 12 deletions src/components/Fortune/Fortune.component.jsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/components/Fortune/Fortune.styles.css

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Fortune/index.js

This file was deleted.

14 changes: 14 additions & 0 deletions src/components/InputSearch/InputSearch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import styled from 'styled-components';

const InputSearchStyled = styled.div`
margin-left: 50px;
`;

export default function InputSearch({ search }) {
return (
<InputSearchStyled>
<input type="text" placeholder="Search" onChange={search} />
</InputSearchStyled>
);
}
Empty file.
1 change: 1 addition & 0 deletions src/components/InputSearch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './InputSearch';
9 changes: 0 additions & 9 deletions src/components/Layout/Layout.component.jsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Layout/Layout.styles.css

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Layout/index.js

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/NavBar/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { FcManager } from 'react-icons/fc';
import InputSearch from '../InputSearch';
import { NavBarStyled } from './NavBar.styles';

function NavBar({ search }) {
return (
<NavBarStyled>
<InputSearch search={search} />
<div>
<FcManager size="60" />
</div>
</NavBarStyled>
);
}

export default NavBar;
10 changes: 10 additions & 0 deletions src/components/NavBar/NavBar.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from 'styled-components';

export const NavBarStyled = styled.div`
background-color: #5472ba;
display: flex;
align-items: center;
justify-content: space-between;
`;

export const NavRightIconStyled = styled.div``;
1 change: 1 addition & 0 deletions src/components/NavBar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './NavBar';
14 changes: 0 additions & 14 deletions src/components/Private/Private.component.jsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Private/index.js

This file was deleted.

20 changes: 20 additions & 0 deletions src/components/VideoCard/VideoCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { Container, Title } from './VideoCard.styles';

const VideoCard = ({ video, handleVideoSelected }) => {
return (
<Container>
<div role="button">
<img alt={video.snippet.description} src={video.snippet.thumbnails.default.url} />
<div>
<Title>{video.snippet.title}</Title>
</div>
</div>
<button type="button" onClick={() => handleVideoSelected(video)}>
View details
</button>
</Container>
);
};

export default VideoCard;
15 changes: 15 additions & 0 deletions src/components/VideoCard/VideoCard.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from 'styled-components';

export const Container = styled.div`
border-bottom: 1px solid #cccccc;
border-radius: 5px;
padding: 20px;
text-align: left;
:hover {
background-color: #374b7a;
}
`;

export const Title = styled.div`
color: white;
`;
1 change: 1 addition & 0 deletions src/components/VideoCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './VideoCard';
36 changes: 36 additions & 0 deletions src/components/VideoDetail/VideoDetail.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import styled from 'styled-components';

const VideoStyled = styled.div`
.video {
margin-top: 50px;
width: 100%;
height: 300px;
}
`;
const Title = styled.h4`
color: #b9b1b1;
`;

const VideoDetail = ({ video }) => {
if (!video) {
return (
<div>
<Title>Select a video</Title>
</div>
);
}
const videoSrc = `https://www.youtube.com/embed/${video.id.videoId}`;
return (
<VideoStyled>
<iframe className="video" src={videoSrc} title="Video" />

<div>
<Title>{video.snippet.title}</Title>
<Title>{video.snippet.description}</Title>
</div>
</VideoStyled>
);
};

export default VideoDetail;
1 change: 1 addition & 0 deletions src/components/VideoDetail/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './VideoDetail';
23 changes: 23 additions & 0 deletions src/components/VideoList/VideoList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import styled from 'styled-components';
import VideoCard from '../VideoCard';

const VideoListContainer = styled.div`
text-align: center;
`;

export default function VideoList({ videos, handleVideoSelected }) {
if (!videos) {
return <div />;
}
const renderedVideos = videos.map((video) => {
return (
<VideoCard
key={Math.random()}
video={video}
handleVideoSelected={handleVideoSelected}
/>
);
});
return <VideoListContainer>{renderedVideos}</VideoListContainer>;
Comment on lines +13 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is common to see the map usage inside the component without creating a variable with it.
i.e.

return (
  <VideoListContainer>
    {videos.map(...
    )}
  </VideoListContainer>

}
1 change: 1 addition & 0 deletions src/components/VideoList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './VideoList';
Loading