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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_API_YOUTUBE_KEY = AIzaSyAOsyZMq5msH04OZ9W7Y_fQX--TictP_v8

Choose a reason for hiding this comment

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

I suggest removing this file from git, you should never upload secrets to your git repository and, I suggest creating a file called .env.example with all the needed variables

REACT_APP_API_YOUTUBE_KEY=

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"react/jsx-filename-extension": "error",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react-hooks/exhaustive-deps": "warn",
"import/no-unresolved": ["off", { "ignore": [".css$"] }],
"import/prefer-default-export": "off",
Expand Down
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
58 changes: 0 additions & 58 deletions src/components/App/App.component.jsx

This file was deleted.

69 changes: 69 additions & 0 deletions src/components/App/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { useReducer } from 'react';
import { Switch, Route, BrowserRouter } from 'react-router-dom';
import styled from 'styled-components';
import AuthProvider from '../../providers/Auth/Auth.provider';
import VideoDetail from '../VideoDetail';
import NavBar from '../NavBar';
import HomePage from '../../pages/Home';
import SearchContext from '../../state/SearchContext';
import SearchReducer from '../../state/SearchReducer';
import LocalThemeProvider from '../../state/ThemeContext.provider';
import VideoProvider from '../../providers/Video/Video.provider';
import Login from '../../pages/Login/Login';
import FavoritesProvider from '../../providers/Favorites/Favorites';
import FavoriteVideos from '../../pages/FavoriteVideos/FavoriteVideos';
import FavoriteVideoDetail from '../../pages/FavoriteVideoDetail/FavoriteVideoDetail';
import Private from '../Private/Private.component';
import NotFound from '../../pages/NotFound/NotFound';

function App() {
const [state, dispatch] = useReducer(SearchReducer, {
search: 'Wizeline',
video: null,
});

const AppStyled = styled.div`
width: 100%;
height: 100vh;
`;

return (
<BrowserRouter>
<AuthProvider>
<AppStyled>
<VideoProvider>
<LocalThemeProvider>
<FavoritesProvider>
<SearchContext.Provider value={{ state, dispatch }}>
<NavBar />
<Switch>
<Route exact path="/">
<HomePage />
</Route>
<Route exact path="/video">
<VideoDetail />
</Route>
<Route exact path="/login">
<Login />
</Route>
<Private exact path="/favorites">
<FavoriteVideos />
</Private>
<Private exact path="/favoritedetails">
<FavoriteVideoDetail />
</Private>
Comment on lines +43 to +54

Choose a reason for hiding this comment

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

With the routes /video and, /favorites you are not going to give the feature of URL sharing one of the main reasons to implement routing. I recommend changing them to /video/:id and, /favorites/:id and extract the id inside the corresponding component using a hook.

import { useParams } from 'react-router-dom';
....
function Component () {
  ...
  const { id } = useParams();
}

<Route path="*">
<NotFound />
</Route>
</Switch>
</SearchContext.Provider>
</FavoritesProvider>
</LocalThemeProvider>
</VideoProvider>
</AppStyled>
</AuthProvider>
</BrowserRouter>
);
}

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.

26 changes: 26 additions & 0 deletions src/components/InputSearch/InputSearch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { useContext } from 'react';
import styled from 'styled-components';
import { VideoContext } from '../../providers/Video/Video.provider';

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

export default function InputSearch() {
const { searchTerm, setSearchTerm } = useContext(VideoContext);

const handleChangeSearchInput = (value) => {
setSearchTerm(value);
};

return (
<InputSearchStyled>
<input
type="text"
placeholder="Search"
onChange={(event) => handleChangeSearchInput(event.target.value)}
value={searchTerm}
/>
</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.

55 changes: 55 additions & 0 deletions src/components/NavBar/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import { Link, useHistory } from 'react-router-dom';
import { FcManager, FcHome, FcLike } from 'react-icons/fc';
import { GiExitDoor } from 'react-icons/gi';
import InputSearch from '../InputSearch';
import { useAuth } from '../../providers/Auth/Auth.provider';
import { NavBarStyled, LinkText } from './NavBar.styles';

function NavBar() {
const { authenticated, logout } = useAuth();
const history = useHistory();

function RemoveAuth(event) {
event.preventDefault();
logout();
history.push('/');
}

return (
<NavBarStyled>
<InputSearch />
<div>
{authenticated ? (
<>
<Link to="/">
<FcHome size="50" />
</Link>

<Link to="/favorites">
<LinkText>
<FcLike size="50" />
</LinkText>
</Link>
<Link to="/" onClick={RemoveAuth}>
<LinkText>
<GiExitDoor size="60" />
</LinkText>
</Link>
</>
) : (
<div>
<Link to="/">
<FcHome size="50" />
</Link>
<Link to="/login">
<FcManager size="60" />
</Link>
</div>
)}
</div>
</NavBarStyled>
);
}

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

export const NavBarStyled = styled.div`
background-color: ${(props) => props.theme.navBar};
display: flex;
align-items: center;
justify-content: space-between;
height: 60px;
`;

export const LinkText = styled.span`
cursor: hand;
color: ${(props) => props.theme.cardBg};
`;
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';
1 change: 0 additions & 1 deletion src/components/Private/index.js

This file was deleted.

Binary file added src/components/VideoCard/.VideoCard.jsx.swo
Binary file not shown.
Binary file added src/components/VideoCard/.VideoCard.jsx.swp
Binary file not shown.
27 changes: 27 additions & 0 deletions src/components/VideoCard/VideoCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Container, Title } from './VideoCard.styles';

const VideoCard = ({ video, handleVideoSelected, isFavorite }) => {
if (!video) {
return <div>No video </div>;
}

return (
<Container>
<Link
to={isFavorite ? '/favoritedetails' : '/video'}
onClick={() => handleVideoSelected(video)}
>
<div>
<img alt="" src={video.snippet.thumbnails.default.url} />
<div>
<Title>{video.snippet.title}</Title>
</div>
</div>
</Link>
</Container>
);
};

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

export const Container = styled.div`
display: flex;
flex-direction: column;
border-bottom: 1px solid #cccccc;
border-radius: 5px;
padding: 20px;
max-width: 320px;
min-width: 320px;
margin: 20px;
background-color: ${(props) => props.theme.cardBg};
a {
text-decoration: none;
}

:hover {
background-color: ${(props) => props.theme.overBg};
}
box-shadow: 0px 0px 5px 1px black;
`;

export const Title = styled.p`
color: ${(props) => props.theme.textcolor};
text-decoration: none;
font-style: normal;
font-size: 20px;
align-items: left;
color: ${(props) => props.theme.text};
font-weight: bold;
`;
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';
Loading