forked from villacoder/react-certification-2021
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mini-Challenge 4: State management #87
Open
LuisRamirezHdz
wants to merge
17
commits into
cvillanueva84:master
Choose a base branch
from
LuisRamirezHdz:StateManagement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
92da252
Test
LuisRamirezHdz a9e5ab4
Header
LuisRamirezHdz 80fa142
Mini-Challenge 1: Core Concepts and Styling
LuisRamirezHdz 9bae26c
Mini-Challenge 2: Intro to Testing
LuisRamirezHdz e636b57
Corrections from the feedback.
LuisRamirezHdz 428754b
Videos in the Home View are fetched from the YouTube API and displaye…
LuisRamirezHdz 61b943f
Display the video player and the information for the selected video
LuisRamirezHdz 9adf2da
Display a list of related videos
LuisRamirezHdz aff458f
Apply styles to the new components
LuisRamirezHdz bd720a3
Create test cases
LuisRamirezHdz 41ed8d2
Rename youtube.js to YouTube.js
LuisRamirezHdz ad60867
Creating a custom hook for the API calls
LuisRamirezHdz a639c75
Merge branch 'Hooks' of https://github.com/LuisRamirezHdz/react-certi…
LuisRamirezHdz 7b2897d
Corrections form the second feedback
LuisRamirezHdz 362e0df
over-flow hidden
LuisRamirezHdz 04baca4
The search term and the apperance theme are stored on the global context
LuisRamirezHdz 732cf1d
useReducer hook is implemented to manage the Global State
LuisRamirezHdz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.env | ||
|
||
# testing | ||
/coverage | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
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'; | ||
require('dotenv').config(); | ||
const KEY = process.env.KEY_YT; | ||
export default axios.create({ | ||
baseURL: 'https://www.googleapis.com/youtube/v3/', | ||
params: { | ||
part: 'snippet', | ||
maxResults: 15, | ||
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
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 App from './App.component'; | ||
import StoreProvider from '../../state/Store.provider'; | ||
import { render, screen } from '@testing-library/react'; | ||
describe('App', () => { | ||
it('Rendiring the home page ', () => { | ||
render( | ||
<StoreProvider> | ||
<App /> | ||
</StoreProvider> | ||
); | ||
expect(screen.getByTestId('location-home')).toBeInTheDocument(); | ||
}); | ||
}); |
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,39 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
const CardBody = styled.div` | ||
width: 100%; | ||
height: 20rem; | ||
cursor: pointer; | ||
overflow: hidden; | ||
`; | ||
const ImageCard = styled.div` | ||
width: 100%; | ||
height: 10rem; | ||
background-image: url(${(props) => props.imageUrl}); | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
`; | ||
const WraperText = styled.div` | ||
padding: 0.5rem; | ||
`; | ||
const Title = styled.div` | ||
font-weight: 600; | ||
font-size: 1.1rem; | ||
`; | ||
const Description = styled.div` | ||
font-size: 0.7rem; | ||
`; | ||
|
||
function Card({ image, title, description }) { | ||
return ( | ||
<CardBody id="cardBody"> | ||
<ImageCard imageUrl={image}></ImageCard> | ||
<WraperText> | ||
<Title>{title}</Title> | ||
<Description>{description}</Description> | ||
</WraperText> | ||
</CardBody> | ||
); | ||
} | ||
|
||
export default Card; |
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,21 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Card from './Card.component'; | ||
|
||
describe('Card', () => { | ||
beforeEach(() => { | ||
render( | ||
<Card | ||
image="https://yt3.ggpht.com/ytc/AAUvwnighSReQlmHl_S_vSfvnWBAG5Cw4A0YxtE0tm5OpQ=s800-c-k-c0xffffffff-no-rj-mo" | ||
title="Test title" | ||
description="Test description" | ||
></Card> | ||
); | ||
}); | ||
test('should contains a title', () => { | ||
expect(screen.getByText(/title/i)).toBeInTheDocument(); | ||
}); | ||
test('should contains a description', () => { | ||
expect(screen.getByText('Test description')).toBeInTheDocument(); | ||
}); | ||
}); |
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 @@ | ||
export { default } from './Card.component'; |
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,34 @@ | ||
import React from 'react'; | ||
import Card from '../../components/Card'; | ||
import { Link } from 'react-router-dom'; | ||
function Cards(props) { | ||
const filteredVideos = props.videos.items.filter( | ||
(video) => video.id.kind === 'youtube#video' | ||
); | ||
return ( | ||
<> | ||
{filteredVideos.map((video) => { | ||
return ( | ||
<Link | ||
key={video.id.videoId} | ||
to={{ | ||
pathname: `/${video.id.videoId}`, | ||
state: { | ||
videoTitle: video.snippet.title, | ||
videoDescription: video.snippet.description, | ||
}, | ||
}} | ||
> | ||
<Card | ||
image={video.snippet.thumbnails.high.url} | ||
title={video.snippet.title} | ||
description={video.snippet.description} | ||
></Card> | ||
</Link> | ||
); | ||
})} | ||
</> | ||
); | ||
} | ||
|
||
export default Cards; |
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,56 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Cards from './Cards.component'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
describe('Cards', () => { | ||
beforeEach(() => { | ||
const video = { | ||
items: [ | ||
{ | ||
kind: 'youtube#searchResult', | ||
etag: '7VY0u60YdqamyHOCAufd7r6qTsQ', | ||
id: { | ||
kind: 'youtube#video', | ||
videoId: 'HYyRZiwBWc8', | ||
}, | ||
snippet: { | ||
publishedAt: '2019-04-18T18:48:04Z', | ||
channelId: 'UCPGzT4wecuWM0BH9mPiulXg', | ||
title: 'Test title', | ||
description: | ||
'Wizeline continues to offer a Silicon Valley culture in burgeoning innovation hubs like Mexico and Vietnam. In 2018, our Guadalajara team moved into a ...', | ||
thumbnails: { | ||
default: { | ||
url: 'https://i.ytimg.com/vi/HYyRZiwBWc8/default.jpg', | ||
width: 120, | ||
height: 90, | ||
}, | ||
medium: { | ||
url: 'https://i.ytimg.com/vi/HYyRZiwBWc8/mqdefault.jpg', | ||
width: 320, | ||
height: 180, | ||
}, | ||
high: { | ||
url: 'https://i.ytimg.com/vi/HYyRZiwBWc8/hqdefault.jpg', | ||
width: 480, | ||
height: 360, | ||
}, | ||
}, | ||
channelTitle: 'Wizeline', | ||
liveBroadcastContent: 'none', | ||
publishTime: '2019-04-18T18:48:04Z', | ||
}, | ||
}, | ||
], | ||
}; | ||
render( | ||
<BrowserRouter> | ||
<Cards videos={video} /> | ||
</BrowserRouter> | ||
); | ||
}); | ||
test('should contains a title corresponding to the card render', () => { | ||
expect(screen.getByText(/title/i)).toBeInTheDocument(); | ||
}); | ||
}); |
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 @@ | ||
export { default } from './Cards.component'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional:
Consider moving these styles to a separate file to keep
App.component.jsx
tidier