forked from wizeline/react-certification-2020
-
Notifications
You must be signed in to change notification settings - Fork 73
Mini challenge 4 state management #52
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
Open
lex-villa
wants to merge
37
commits into
erickwize:master
Choose a base branch
from
lex-villa:Mini-Challenge-4--State-Management
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
37 commits
Select commit
Hold shift + click to select a range
042e6c5
styled components installed
lex-villa de0dfb9
Navigation folder structure added
lex-villa 7e4b5ea
header started and burger button ready
lex-villa 9cad491
header started and burger button ready
lex-villa f1c0180
burger button responsive
lex-villa 7fa1c3a
sidreDrawer added
lex-villa cc8ed92
sidreDrawer added
lex-villa 2891168
NavLinks added
lex-villa 39a93a9
NavLinks added
lex-villa 8f595b7
seacrh bar added
lex-villa 140438e
seacrh bar added
lex-villa 307c4cf
cursor text added to label
lex-villa ee3ea0c
toggle and log component added
lex-villa 7cc1863
toggle and log component added
lex-villa 94f63cf
grid in home view added
lex-villa 11d9000
grid in home view added
lex-villa 6ff4c18
test to <VideoListHome /> added
lex-villa 81f0798
test to <VideoListHome /> added
lex-villa d67c05e
test config added
lex-villa 97311d2
first try to have the text plain report from the testing
lex-villa 9bdf31e
improvements based on feedback
lex-villa 615d6a4
Merge branch 'Mini-Challenge-1--Core-Concepts-and-Styling' of https:/…
lex-villa 03ddc60
improvements based on feedback
lex-villa 25769bc
Merge pull request #1 from lex-villa/Mini-Challenge-1--Core-Concepts-…
lex-villa 6067848
fetch info for home view is ready
lex-villa c394dce
search input functionality added
lex-villa fd9e0cb
icon input functionality added
lex-villa 0e6e6db
video player shows the clicked video
lex-villa 9c4004b
video player shows the clicked video
lex-villa 584be7d
suggested videos are fetched correctly
lex-villa acad282
suggested videos are fetched correctly
lex-villa 25777ec
list of suggested videos styled
lex-villa 60ce15a
video player styled
lex-villa 9bf15da
global context implemented
lex-villa e630c4b
context management improved
lex-villa 6f06db6
context management improved
lex-villa c490633
dark mode with styled components added
lex-villa 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 hidden or 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 @@ | ||
| REACT_APP_GOOGLE_API_KEY=AIzaSyDN0P1UB4W39-XdmmA9wniCAlXA0f3WprU | ||
| REACT_APP_YOUTUBE_API_V3_SEARCH_URL=https://www.googleapis.com/youtube/v3/search | ||
| REACT_APP_YOUTUBE_API_V3_VIDEOS_URL=https://www.googleapis.com/youtube/v3/videos | ||
This file contains hidden or 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 hidden or 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,4 @@ | ||
| { | ||
| "plugins": ["@babel/plugin-transform-react-jsx"], | ||
| "presets": ["@babel/env", "@babel/react"] | ||
| } |
This file contains hidden or 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,13 @@ | ||
| --------------------------------|----------|----------|----------|----------|----------------| | ||
| File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | | ||
| --------------------------------|----------|----------|----------|----------|----------------| | ||
| CardHomePreview\ | 100 | 100 | 100 | 100 | | | ||
| CardHomePreview.component.jsx | 100 | 100 | 100 | 100 | | | ||
| index.js | 100 | 100 | 100 | 100 | | | ||
| VideoListHome\ | 100 | 100 | 100 | 100 | | | ||
| VideoListHome.component.jsx | 100 | 100 | 100 | 100 | | | ||
| --------------------------------|----------|----------|----------|----------|----------------| | ||
| All files | 100 | 100 | 100 | 100 | | | ||
| --------------------------------|----------|----------|----------|----------|----------------| | ||
|
|
||
| Done |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,58 +1,40 @@ | ||
| import React, { useLayoutEffect } from 'react'; | ||
| import React, { useContext } from 'react'; | ||
| import { BrowserRouter, Switch, Route } from 'react-router-dom'; | ||
| import { ThemeProvider } from 'styled-components'; | ||
|
|
||
| import AuthProvider from '../../providers/Auth'; | ||
| import { GlobalStyles } from '../GlobalStyles.js/GlobalStyles'; | ||
| import { lightTheme, darkTheme } from '../../utils/themes'; | ||
| import HomePage from '../../pages/Home'; | ||
| import LoginPage from '../../pages/Login'; | ||
| import NotFound from '../../pages/NotFound'; | ||
| import SecretPage from '../../pages/Secret'; | ||
| import Private from '../Private'; | ||
| import Fortune from '../Fortune'; | ||
| import VideoDetails from '../../pages/VideoDetails/VideoDetails.component'; | ||
| import Layout from '../Layout'; | ||
| import { random } from '../../utils/fns'; | ||
| import { Context } from '../../utils/store/Store'; | ||
|
|
||
| function App() { | ||
| useLayoutEffect(() => { | ||
| const { body } = document; | ||
| const App = () => { | ||
| const state = useContext(Context)[0]; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend using: |
||
|
|
||
| function rotateBackground() { | ||
| const xPercent = random(100); | ||
| const yPercent = random(100); | ||
| body.style.setProperty('--bg-position', `${xPercent}% ${yPercent}%`); | ||
| } | ||
|
|
||
| const intervalId = setInterval(rotateBackground, 3000); | ||
| body.addEventListener('click', rotateBackground); | ||
|
|
||
| return () => { | ||
| clearInterval(intervalId); | ||
| body.removeEventListener('click', rotateBackground); | ||
| }; | ||
| }, []); | ||
| const routes = ( | ||
| <Switch> | ||
| <Route path="/" exact> | ||
| <HomePage /> | ||
| </Route> | ||
| <Route path="/videoDetails/:videoId"> | ||
| <VideoDetails /> | ||
| </Route> | ||
| </Switch> | ||
| ); | ||
|
|
||
| return ( | ||
| <BrowserRouter> | ||
| <AuthProvider> | ||
| <Layout> | ||
| <Switch> | ||
| <Route exact path="/"> | ||
| <HomePage /> | ||
| </Route> | ||
| <Route exact path="/login"> | ||
| <LoginPage /> | ||
| </Route> | ||
| <Private exact path="/secret"> | ||
| <SecretPage /> | ||
| </Private> | ||
| <Route path="*"> | ||
| <NotFound /> | ||
| </Route> | ||
| </Switch> | ||
| <Fortune /> | ||
| </Layout> | ||
| </AuthProvider> | ||
| <ThemeProvider theme={state.isDarkTheme ? darkTheme : lightTheme}> | ||
| <> | ||
| <GlobalStyles /> | ||
| <Layout> | ||
| <main>{routes}</main> | ||
| </Layout> | ||
| </> | ||
| </ThemeProvider> | ||
| </BrowserRouter> | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| export default App; | ||
25 changes: 25 additions & 0 deletions
25
src/components/CardHomePreview/CardHomePreview.component.jsx
This file contains hidden or 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,25 @@ | ||
| import React from 'react'; | ||
| import { useHistory } from 'react-router-dom'; | ||
| import { Card } from './CardHomePreview.styled'; | ||
|
|
||
| const CardHomePreview = (props) => { | ||
| const history = useHistory(); | ||
|
|
||
| const onClickHandler = () => { | ||
| history.push(`/videoDetails/${props.videoId}`); | ||
| }; | ||
|
|
||
| return ( | ||
| <Card onClick={onClickHandler}> | ||
| <div className="card-home-review__image"> | ||
| <img src={`${props.image}`} alt={props.title} /> | ||
| </div> | ||
| <div className="card-home-review__info"> | ||
| <h2>{props.title}</h2> | ||
| <p>{props.description}</p> | ||
| </div> | ||
| </Card> | ||
| ); | ||
| }; | ||
|
|
||
| export default CardHomePreview; |
This file contains hidden or 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,44 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const Card = styled.div` | ||
| position: relative; | ||
| margin: 0; | ||
| box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); | ||
| border-radius: 6px; | ||
| padding: 1rem; | ||
| overflow: hidden; | ||
| background: ${({ theme }) => theme.backgroundCard}; | ||
| width: 100%; | ||
| height: 100%; | ||
| cursor: pointer; | ||
|
|
||
| .card-home-review__image { | ||
| width: 100%; | ||
| height: 7.5rem; | ||
| margin-right: 1.5rem; | ||
|
|
||
| img { | ||
| width: 100%; | ||
| height: 100%; | ||
| object-fit: cover; | ||
| } | ||
| } | ||
|
|
||
| .card-home-review__info { | ||
| padding: 1rem; | ||
| text-align: center; | ||
|
|
||
| h2, | ||
| p { | ||
| margin: 0 0 0.5rem 0; | ||
| } | ||
|
|
||
| h2 { | ||
| font-size: 20px; | ||
| } | ||
|
|
||
| p { | ||
| font-size: 16px; | ||
| } | ||
| } | ||
| `; |
This file contains hidden or 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 './CardHomePreview.component'; |
This file contains hidden or 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,52 @@ | ||
| import React from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
|
|
||
| import { ButtonContainer } from './Button.styled'; | ||
|
|
||
| const Button = (props) => { | ||
| if (props.href) { | ||
| return ( | ||
| <ButtonContainer> | ||
| <a | ||
| className={`button button--${props.size || 'default'} ${ | ||
| props.inverse && 'button--inverse' | ||
| } ${props.danger && 'button--danger'}`} | ||
| href={props.href} | ||
| > | ||
| {props.children} | ||
| </a> | ||
| </ButtonContainer> | ||
| ); | ||
| } | ||
| if (props.to) { | ||
| return ( | ||
| <ButtonContainer> | ||
| <Link | ||
| to={props.to} | ||
| exact={props.exact} | ||
| className={`button button--${props.size || 'default'} ${ | ||
| props.inverse && 'button--inverse' | ||
| } ${props.danger && 'button--danger'}`} | ||
| > | ||
| {props.children} | ||
| </Link> | ||
| </ButtonContainer> | ||
| ); | ||
| } | ||
| return ( | ||
| <ButtonContainer> | ||
| <button | ||
| className={`button button--${props.size || 'default'} ${ | ||
| props.inverse && 'button--inverse' | ||
| } ${props.danger && 'button--danger'}`} | ||
| type="button" | ||
| onClick={props.onClick} | ||
| disabled={props.disabled} | ||
| > | ||
| {props.children} | ||
| </button> | ||
| </ButtonContainer> | ||
| ); | ||
| }; | ||
|
|
||
| export default Button; |
This file contains hidden or 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,65 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const ButtonContainer = styled.div` | ||
| .button { | ||
| font: inherit; | ||
| padding: 0.5rem 1.5rem; | ||
| border: 1px solid #ff0055; | ||
| border-radius: 4px; | ||
| background: #ff0055; | ||
| color: white; | ||
| cursor: pointer; | ||
| margin-right: 1rem; | ||
| text-decoration: none; | ||
| display: inline-block; | ||
| } | ||
|
|
||
| .button:focus { | ||
| outline: none; | ||
| } | ||
|
|
||
| .button:hover, | ||
| .button:active { | ||
| background: #ff4382; | ||
| border-color: #ff4382; | ||
| } | ||
|
|
||
| .button--inverse { | ||
| background: transparent; | ||
| color: #ff0055; | ||
| } | ||
|
|
||
| .button--inverse:hover, | ||
| .button--inverse:active { | ||
| color: white; | ||
| background: #ff0055; | ||
| } | ||
|
|
||
| .button--danger { | ||
| background: #830000; | ||
| border-color: #830000; | ||
| } | ||
|
|
||
| .button--danger:hover, | ||
| .button--danger:active { | ||
| background: #f34343; | ||
| border-color: #f34343; | ||
| } | ||
|
|
||
| .button:disabled, | ||
| .button:hover:disabled, | ||
| .button:active:disabled { | ||
| background: #ccc; | ||
| color: #979797; | ||
| border-color: #ccc; | ||
| cursor: not-allowed; | ||
| } | ||
|
|
||
| .button--small { | ||
| font-size: 0.8rem; | ||
| } | ||
|
|
||
| .button--big { | ||
| font-size: 1.5rem; | ||
| } | ||
| `; |
This file contains hidden or 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 './Button.component'; |
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.
I recommend removing this file, you should never upload these types of files