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
42,994 changes: 42,994 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.34",
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@fortawesome/react-fontawesome": "^0.1.14",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^12.1.3",
"hoist-non-react-statics": "^3.3.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-player": "^2.9.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",
"youtube-api-search": "^0.0.5"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -49,8 +58,7 @@
"lint-staged": {
"*.{js, jsx, css, json}": [
"yarn run lint:fix",
"pretty-quick --staged",
"git add"
"pretty-quick --staged"
]
},
"husky": {
Expand Down
14 changes: 8 additions & 6 deletions src/components/App/App.component.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useLayoutEffect } from 'react';
import React, { useState, useLayoutEffect } from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';

import AuthProvider from '../../providers/Auth';
import VideoProvider from '../../providers/VideoSearch';
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 Layout from '../Layout';
import Navigation from '../Navigation';
import { random } from '../../utils/fns';

function App() {
Expand All @@ -30,9 +30,12 @@ function App() {
};
}, []);

const [search, setSearch] = useState('');

return (
<BrowserRouter>
<AuthProvider>
<VideoProvider>
<Navigation />
<Layout>
<Switch>
<Route exact path="/">
Expand All @@ -48,9 +51,8 @@ function App() {
<NotFound />
</Route>
</Switch>
<Fortune />
</Layout>
</AuthProvider>
</VideoProvider>
</BrowserRouter>
);
}
Expand Down
14 changes: 14 additions & 0 deletions src/components/App/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App.component';

describe('App', () => {
it('renders Main Container', () => {
const { getByRole } = render(<App />);
expect(getByRole('main')).not.toBeUndefined();
});
it('renders Navigation Bar', () => {
const { getByRole } = render(<App />);
expect(getByRole('banner')).not.toBeUndefined();
});
});
19 changes: 19 additions & 0 deletions src/components/Card/Card.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render , screen } from '@testing-library/react';
import { BrowserRouter as Router } from 'react-router-dom';
import Card from './index';

const MOCK_PROPS = {
imgUrl : "demo_url",
title : "Demo Title",
description : "Demo Description",
};

describe('Card', () => {
it('renders a Video title', () => {
const { getAllByRole } = render(
<Card props={MOCK_PROPS} />
);
expect(getAllByRole('heading')[0].tagName).toBe('H3');
});
});
17 changes: 17 additions & 0 deletions src/components/Card/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, {useState} from "react";
import Styled from "./styled";

const Card = ({ video, handleVideoSelected }) =>{

return (
<Styled.Card>
<Styled.CardImg imgUrl={video.snippet.thumbnails.medium.url} onClick={() => handleVideoSelected(video)} ></Styled.CardImg>
<Styled.CardContent>
<Styled.CardTitle onClick={() => handleVideoSelected(video)}> {video.snippet.title} </Styled.CardTitle>
<Styled.CardDescription> {video.snippet.description} </Styled.CardDescription>
</Styled.CardContent>
</Styled.Card>
);
};

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

const Card = styled.div`
width: 32%;
float: left;
background: #FFF;
margin-right: 14px;
min-height: 490px;
margin-bottom: 14px;
box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%);
`;

const CardImg = styled.div`
min-height: 180px;
background-position: center top;
background-size: auto 100%;
background-image: url(${props => props.imgUrl});
cursor: pointer;
`;

const CardContent = styled.div`
display: grid;
width: 100%;
padding: 20px;
`;

const CardTitle = styled.h3`
font-size: 1.25rem;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 500;
line-height: 1.6;
letter-spacing: 0.0075em;
cursor: pointer;
`;

const CardDescription = styled.p`
font-size: 0.875rem;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 400;
line-height: 1.43;
letter-spacing: 0.01071em;
color: rgba(0, 0, 0, 0.54);
`;

const Styled = { Card, CardImg, CardContent, CardTitle, CardDescription };
export default Styled;
2 changes: 0 additions & 2 deletions src/components/Layout/Layout.styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: -3rem;
}
10 changes: 10 additions & 0 deletions src/components/Navigation/Navigation.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { render } from '@testing-library/react';
import Navigation from './index';

describe('Navigation', () => {
it('renders Search Input', () => {
const { getByRole } = render(<Navigation />);
expect(getByRole('button')).not.toBeUndefined();
});
});
71 changes: 71 additions & 0 deletions src/components/Navigation/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import { Switch, FormControlLabel } from '@material-ui/core';
import Styled from "./styled";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faBars, faUser } from '@fortawesome/free-solid-svg-icons'
import {useVideoSearch} from './../../providers/VideoSearch'
import {API_KEY} from '../../utils/constants';
import YTSerach from 'youtube-api-search';
//import mockedData from "../../youtube-videos-mock.json";

const Navigation = () => {
const {
search,
darkMode,
selectedVideo,
setDarkMode,
setSearch,
setItems,
setSelectedVideo,
setRelatedVideos,
} = useVideoSearch();

const handleChange = (event) => {
setSearch(event.target.value);
};

const handleSubmit = (event) => {
event.preventDefault();

if(search!=''){
YTSerach({key: API_KEY, term: search, maxResults: 5 },function(videos){
setItems(videos);
setSelectedVideo(videos[0]);
} );
YTSerach({key: API_KEY, relatedToVideoId: selectedVideo.id.videoId, maxResults: 4 },function(rVideos){
setRelatedVideos(rVideos);
} );

}

};

return (
<Styled.Navigation>
<Styled.NavigationContainer>
<Styled.MainMenu><FontAwesomeIcon icon={faBars}/></Styled.MainMenu>
<Styled.SearchBar>
<form style={{ display: 'inline' }} onSubmit={handleSubmit}>
<Styled.SearchInput
placeholder="Search..."
type="text"
value={search}
onChange={handleChange}
/>
</form>
</Styled.SearchBar>
<Styled.EmptyBar />
<Styled.SetupBar>
<FormControlLabel
control={<Switch checked={darkMode} onChange={setDarkMode} />}
label="Dark Mode"
/>
<Styled.SessionMenu><FontAwesomeIcon icon={faUser}/></Styled.SessionMenu>
</Styled.SetupBar>
</Styled.NavigationContainer>
</Styled.Navigation>
);
}


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

const Navigation = styled.header`
width: 100%;
display: flex;
z-index: 1100;
box-sizing: border-box;
flex-shrink: 0;
flex-direction: column;
color: #fff;
background-color: #1C5476;
`;

const NavigationContainer = styled.div`
display: flex;
position: relative;
align-items: center;
min-height: 64px;
padding-left: 24px;
padding-right: 24px;
`;

const MainMenu = styled.button`
color: #FFF;
padding: 12px;
overflow: visible;
font-size: 1rem;
text-align: center;
background: none;
border: none;
`;

const SearchBar = styled.div`
width: 30%;
position: relative;
padding-left: 24px;
padding-right: 16px;
border-radius: 4px;
`;

const SearchInput = styled.input`
font: inherit;
width: 100%;
border: 0;
padding: 5px;
margin: 0;
display: block;
min-width: 0;
box-sizing: content-box;
letter-spacing: inherit;
opacity: 0.5;
border-radius: 4px;
`;


const EmptyBar = styled.div`
width:50%;
`;

const SetupBar = styled.div`
width:15%;
display: flex;
`;


const DarkMode = styled.div`
font-weight: bold;
padding: 5px 10px;
`;

const SessionMenu = styled.div`
font-weight: bold;
font-size: 1.3em;
padding-left: 15px;
`;


const Styled = { Navigation, NavigationContainer, MainMenu, SearchBar, SearchInput, SetupBar, DarkMode, SessionMenu, EmptyBar };
export default Styled;
Loading