forked from wdonet/react-certification-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/mini challenge5 #4
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
fernandaMadin
wants to merge
8
commits into
master
Choose a base branch
from
feature/miniChallenge5
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
8 commits
Select commit
Hold shift + click to select a range
fb7f23b
[new] - Create app components, home page and add unit testing
71cbcfc
[update] - Index
7c4e9e7
[update] -Update dependencies
2079dfe
[update] -Update dependencies
34f9972
Challenge 3: Hooks
79f14bb
[new] Add global context
0bbdd8c
[update] - App router and code changes
c611915
[update] library update
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 @@ | ||
| REACT_APP_API_KEY=AIzaSyCbnwRIBvWCoQGaLIOFUx4rhLHg-Sb1a8s | ||
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 @@ | ||
| ------------------------------|----------|----------|----------|----------|-------------------| | ||
| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | | ||
| ------------------------------|----------|----------|----------|----------|-------------------| | ||
| All files | 61.61 | 50 | 50 | 62.16 | | | ||
| components/Account | 78.57 | 50 | 40 | 84.62 | | | ||
| index.jsx | 70 | 50 | 25 | 77.78 | 23,26 | | ||
| styled.js | 100 | 50 | 100 | 100 | 14 | | ||
| components/App | 0 | 100 | 0 | 0 | | | ||
| App.component.jsx | 0 | 100 | 0 | 0 | 14,15,17,18,19,23 | | ||
| components/Layout | 100 | 100 | 100 | 100 | | | ||
| index.jsx | 100 | 100 | 100 | 100 | | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| components/NavBar | 90.91 | 100 | 50 | 90.91 | | | ||
| index.jsx | 75 | 100 | 50 | 75 | 22 | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| components/SearchInput | 92.31 | 100 | 75 | 92.31 | | | ||
| index.jsx | 91.67 | 100 | 75 | 91.67 | 21 | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| components/SideMenu | 92.31 | 50 | 75 | 92.31 | | | ||
| index.jsx | 80 | 50 | 50 | 80 | 22 | | ||
| styled.js | 100 | 50 | 100 | 100 | 9,26 | | ||
| components/VideoCard | 100 | 100 | 100 | 100 | | | ||
| index.jsx | 100 | 100 | 100 | 100 | | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| components/VideoGrid | 100 | 100 | 100 | 100 | | | ||
| index.jsx | 100 | 100 | 100 | 100 | | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| components/VideosList | 0 | 0 | 0 | 0 | | | ||
| index.jsx | 0 | 0 | 0 | 0 | 5,6,9,13 | | ||
| components/VideosListElement | 0 | 100 | 0 | 0 | | | ||
| index.jsx | 0 | 100 | 0 | 0 | 4,5 | | ||
| styled.js | 0 | 100 | 0 | 0 | 3,9,10,20,26 | | ||
| lib | 100 | 50 | 100 | 100 | | | ||
| youTubeApi.js | 100 | 50 | 100 | 100 | 7,9 | | ||
| pages/Home | 100 | 100 | 100 | 100 | | | ||
| Home.page.jsx | 100 | 100 | 100 | 100 | | | ||
| styled.js | 100 | 100 | 100 | 100 | | | ||
| pages/Login | 0 | 100 | 0 | 0 | | | ||
| Login.page.jsx | 0 | 100 | 0 | 0 | 8,9,12,13,14,17 | | ||
| pages/VideoDetail | 0 | 0 | 0 | 0 | | | ||
| VideoDetail.page.jsx | 0 | 0 | 0 | 0 |... 20,21,23,24,27 | | ||
| index.js | 0 | 0 | 0 | 0 | | | ||
| styled.js | 0 | 100 | 100 | 0 | 3,7,18,27,31,38 | | ||
| ------------------------------|----------|----------|----------|----------|-------------------| |
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
| import React from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
| import { AccountIcon, Dropdown, Button } from './styled'; | ||
| import { AUTH_STORAGE_KEY } from '../../utils/constants'; | ||
| import { storage } from '../../utils/storage'; | ||
| import { useAuth } from '../../providers/Auth'; | ||
| import user from '../../img/user.svg'; | ||
|
|
||
| const Account = () => { | ||
| const { logout } = useAuth(); | ||
| const [openDrop, setOpenDrop] = React.useState(false); | ||
| const isLogged = storage.get(AUTH_STORAGE_KEY); | ||
| const logIn = ( | ||
| <Link to="/login"> | ||
| <span>LogIn</span> | ||
| </Link> | ||
| ); | ||
| const logOut = <Button onClick={() => logout()}>LogOut</Button>; | ||
|
|
||
| return ( | ||
| <div> | ||
| <AccountIcon | ||
| src={user} | ||
| onClick={() => { | ||
| setOpenDrop(!openDrop); | ||
| }} | ||
| /> | ||
| <Dropdown openDrop={openDrop} onClick={() => setOpenDrop(!openDrop)}> | ||
| {isLogged ? logOut : logIn} | ||
| </Dropdown> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Account; |
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,29 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| const AccountIcon = styled.img` | ||
| color: white; | ||
| width: 50px; | ||
| height: 50px; | ||
| float: right; | ||
| margin-left: 30px; | ||
| `; | ||
|
|
||
| const Dropdown = styled.ul` | ||
| position: absolute; | ||
| display: ${({ openDrop }) => (openDrop ? 'block' : 'none')}; | ||
| padding-inline-start: 0px; | ||
| background-color: lightgray; | ||
| padding: 8px; | ||
| margin-top: 40px; | ||
| `; | ||
|
|
||
| const Button = styled.button` | ||
| box-sizing: inherit; | ||
| background-color: transparent; | ||
| font-size: 19px; | ||
| color: white; | ||
| font-weight: bold; | ||
| border: none; | ||
| `; | ||
|
|
||
| export { AccountIcon, Dropdown, 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 |
|---|---|---|
| @@ -1,58 +1,55 @@ | ||
| import React, { useLayoutEffect } from 'react'; | ||
| import React, { useReducer } from 'react'; | ||
| import { BrowserRouter, Switch, Route } from 'react-router-dom'; | ||
|
|
||
| import AuthProvider from '../../providers/Auth'; | ||
| import NavBar from '../NavBar'; | ||
| import Layout from '../Layout'; | ||
| import HomePage from '../../pages/Home'; | ||
| import LoginPage from '../../pages/Login'; | ||
| import VideoDetailPage from '../../pages/VideoDetail'; | ||
| import FavoritesPage from '../../pages/Favorites'; | ||
| import NotFound from '../../pages/NotFound'; | ||
| import SecretPage from '../../pages/Secret'; | ||
| import GlobalContext from '../../state/GlobalContext'; | ||
| import GlobalReducer from '../../state/GlobalReducer'; | ||
| import Private from '../Private'; | ||
| import Fortune from '../Fortune'; | ||
| import Layout from '../Layout'; | ||
| import { random } from '../../utils/fns'; | ||
|
|
||
| function App() { | ||
| useLayoutEffect(() => { | ||
| const { body } = document; | ||
|
|
||
| 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); | ||
| }; | ||
| }, []); | ||
| export default function App() { | ||
| const [videos, setVideos] = React.useState([]); | ||
| const [state, dispatch] = useReducer(GlobalReducer, { | ||
| word: 'Wizeline', | ||
| theme: { | ||
| navBar: '#3fc7cb', | ||
| content: 'white', | ||
| text: 'black', | ||
| }, | ||
| }); | ||
|
|
||
| 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> | ||
| <GlobalContext.Provider value={{ state, dispatch }}> | ||
| <NavBar setVideos={setVideos} /> | ||
| <Layout> | ||
| <Switch> | ||
| <Route exact path="/"> | ||
| <HomePage videos={videos} /> | ||
| </Route> | ||
| <Route exact path="/login"> | ||
| <LoginPage /> | ||
| </Route> | ||
| <Private exact path="/favorites"> | ||
| <FavoritesPage /> | ||
| </Private> | ||
| <Route exact path="/video/:id"> | ||
| <VideoDetailPage /> | ||
| </Route> | ||
| <Route exact path="*"> | ||
| <NotFound /> | ||
| </Route> | ||
| </Switch> | ||
| </Layout> | ||
| </GlobalContext.Provider> | ||
| </AuthProvider> | ||
| </BrowserRouter> | ||
| ); | ||
| } | ||
|
|
||
| export default App; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
| import React from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import Layout from '.'; | ||
|
|
||
| describe('Layout', () => { | ||
| const children = <h1>hello</h1>; | ||
|
|
||
| beforeEach(() => { | ||
| render(<Layout>{children}</Layout>); | ||
| }); | ||
|
|
||
| it('renders all children', () => { | ||
| const layout = screen.getByTestId('layout'); | ||
| expect(layout.children.length).toEqual(1); | ||
| expect(screen.getByText('hello').tagName).toBe('H1'); | ||
| }); | ||
| }); |
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
| import React from 'react'; | ||
| import { Container } from './styled'; | ||
|
|
||
| function Layout({ children }) { | ||
| return ( | ||
| <Container className="container" data-testid="layout"> | ||
| {children} | ||
| </Container> | ||
| ); | ||
| } | ||
|
|
||
| export default Layout; |
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,10 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| const Container = styled.main` | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| `; | ||
|
|
||
| export { Container }; |
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,24 @@ | ||
| import React from 'react'; | ||
| import { BrowserRouter } from 'react-router-dom'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import NavBar from '.'; | ||
| import AuthProvider from '../../providers/Auth'; | ||
|
|
||
| describe('NavBar', () => { | ||
| beforeEach(() => { | ||
| render( | ||
| <BrowserRouter> | ||
| <AuthProvider> | ||
| <NavBar /> | ||
| </AuthProvider> | ||
| </BrowserRouter> | ||
| ); | ||
| }); | ||
|
|
||
| it('renders NavBar and its elements', () => { | ||
| const navBar = screen.getByTestId('navBar'); | ||
| expect(navBar.children.length).toEqual(1); | ||
| const navContent = screen.getByTestId('navContent'); | ||
| expect(navContent.children.length).toEqual(4); | ||
| }); | ||
| }); |
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.
try not to keep this info at git history, it is smt you should handle using env vars