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
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_BASE_URL = https://www.googleapis.com/youtube/v3
REACT_APP_API_KEY = AIzaSyDmDt_il76Hh7Big2gwbYM7IdUCqpyc88A
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_BASE_URL = https://www.googleapis.com/youtube/v3
REACT_APP_API_KEY = AIzaSyDmDt_il76Hh7Big2gwbYM7IdUCqpyc88A
16,049 changes: 16,049 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 18 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
{
"name": "react-certification-2020",
"name": "react-certification-2021",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^12.1.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^0.21.1",
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
"react-scripts": "4.0.3",
"styled-components": "^5.2.1",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint ./src --ext .js,.jsx",
"lint:fix": "eslint ./src --ext .js,.jsx --fix"
"test": "react-scripts test --coverage",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"devDependencies": {
"eslint-config-airbnb": "^18.2.0",
Expand All @@ -45,17 +53,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"lint-staged": {
"*.{js, jsx, css, json}": [
"yarn run lint:fix",
"pretty-quick --staged",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
7 changes: 6 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400&display=swap"
rel="stylesheet"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -21,7 +26,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>React Challenge Andrés Billini</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
7 changes: 7 additions & 0 deletions src/assets/account.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/assets/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions src/assets/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions src/components/App/App.component.copy.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { useLayoutEffect } from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';

import AuthProvider from '../../providers/Auth';
import HomePage from '../../pages/Home';
import VideoDetails from '../../pages/VideoDetails';
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 { random } from '../../utils/fns';

function AppCopy() {
useLayoutEffect(() => {
const { body } = document;

const 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);
};
}, []);

return (
<BrowserRouter>
<AuthProvider>
<Layout>
<Switch>
<Route exact path="/">
<HomePage />
</Route>
<Route exact path="/video/:id">
<VideoDetails />
</Route>
<Route exact path="/login">
<LoginPage />
</Route>
<Private exact path="/secret">
<SecretPage />
</Private>
<Route path="*">
<NotFound />
</Route>
</Switch>
{/* <Fortune /> */}
</Layout>
</AuthProvider>
</BrowserRouter>
);
}

export default AppCopy;
62 changes: 24 additions & 38 deletions src/components/App/App.component.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useLayoutEffect } from 'react';
import React from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';

import AuthProvider from '../../providers/Auth';
Expand All @@ -7,49 +7,35 @@ 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 { random } from '../../utils/fns';
import ThemeBaseProvider from '../../providers/theme';
import VideoDetails from '../../pages/VideoDetails/VideoDetails';

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);
};
}, []);

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>
<ThemeBaseProvider>
<Layout>
<Switch>
<Route exact path="/">
<HomePage />
</Route>
<Route exact path="/video/:id">
<VideoDetails />
</Route>
<Route exact path="/login">
<LoginPage />
</Route>
<Private exact path="/secret">
<SecretPage />
</Private>
<Route path="*">
<NotFound />
</Route>
</Switch>
</Layout>
</ThemeBaseProvider>
</AuthProvider>
</BrowserRouter>
);
Expand Down
17 changes: 17 additions & 0 deletions src/components/App/App.component.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// React
import React from 'react';
// Testing
import { render, screen } from '@testing-library/react';
// Components
import App from './App.component';

describe('App', () => {
beforeEach(() => {
render(<App />);
});
it('renders app component', () => {
expect(screen.getAllByRole('button').length).toEqual(1);
expect(screen.getAllByRole('main').length).toEqual(1);
expect(screen.getByText('Welcome to the Challenge!')).toBeInTheDocument();
});
});
4 changes: 2 additions & 2 deletions src/components/Fortune/Fortune.component.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';

import { useFortune } from '../../utils/hooks/useFortune';
import './Fortune.styles.css';
import { FortuneContainer } from './styles';

function Fortune() {
const { fortune } = useFortune();

return <span className="fortune">{fortune} </span>;
return <FortuneContainer>{fortune}</FortuneContainer>;
}

export default Fortune;
5 changes: 0 additions & 5 deletions src/components/Fortune/Fortune.styles.css

This file was deleted.

7 changes: 7 additions & 0 deletions src/components/Fortune/styles.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from 'styled-components';

export const FortuneContainer = styled.span`
position: fixed;
bottom: 0;
right: 0;
`;
23 changes: 23 additions & 0 deletions src/components/Home/HomeList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
// Components
import Card from '../common/Card';
import { useVideos } from '../../providers/Videos/Videos.provider';

const HomeList = () => {
const { videos } = useVideos();
return (
<>
{videos.map((item) => (
<Card
key={`${item.snippet.title}-${item.snippet.description}`}
title={item.snippet.title}
description={item.snippet.description}
image={item.snippet.thumbnails.high.url}
url={`/video/${item.id.videoId}`}
/>
))}
</>
);
};

export default HomeList;
1 change: 1 addition & 0 deletions src/components/Home/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './HomeList';
Loading