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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.netlify/
17,396 changes: 17,396 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 5 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,26 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-fontawesome": "^0.1.14",
"@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",
"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",
"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"
},
"devDependencies": {
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.13",
"prettier": "^2.1.1",
"pretty-quick": "^3.0.0"
},
"browserslist": {
"production": [
Expand All @@ -45,17 +35,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"
}
Comment on lines -49 to -59
Copy link

Choose a reason for hiding this comment

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

What were the problems with husky?, I might be able to help you with that.

}
}
2 changes: 0 additions & 2 deletions src/components/App/App.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function App() {
return (
<BrowserRouter>
<AuthProvider>
<Layout>
<Switch>
<Route exact path="/">
<HomePage />
Expand All @@ -49,7 +48,6 @@ function App() {
</Route>
</Switch>
<Fortune />
</Layout>
</AuthProvider>
</BrowserRouter>
);
Expand Down
33 changes: 33 additions & 0 deletions src/components/Layout/CardVideo/CardVideo.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import styled from 'styled-components';


const CardContainer = styled.div`
Copy link

Choose a reason for hiding this comment

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

I suggest to put your styled components into its styled.js file, this way you'll have a more cleaner component. You could do something like:

// styled.js
export const CardContainer = styled.div`
  ...
`

// CardVideo.component.jsx
import { CardContainer } from './styled';

width: 350px;
border-radius: 5px;
border: 1px solid #ddd;
margin: 10px;
overflow: hidden;
padding: 15px;
`;

const CardImg = styled.img`
width: 100%;
height: 140px;
`;


function CardVideo(props){
Copy link

Choose a reason for hiding this comment

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

You can extract the props using destructuring, so it is cleaner in your component, like so:

function CardVideo({ item }) {

Check the comment about the extra {} cause I think it wasn't intended.

Copy link

Choose a reason for hiding this comment

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

Now that you are using props, it could be useful to put in place a set of rules for those props, so that the component expects exactly what you meant. Check the documentation for these and let me know if you have any questions:

https://reactjs.org/docs/typechecking-with-proptypes.html

return(
<CardContainer>
<CardImg src={props.item.item.snippet.thumbnails.high.url}/>
<div>
<h4>{props.item.item.snippet.title.toString()}</h4>
<p>{props.item.item.snippet.description}</p>
</div>
</CardContainer>
);
}


export default CardVideo;
1 change: 1 addition & 0 deletions src/components/Layout/CardVideo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './CardVideo.component';
105 changes: 105 additions & 0 deletions src/components/Layout/Navbar/Navbar.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faBars, faUser } from '@fortawesome/free-solid-svg-icons'
Copy link

Choose a reason for hiding this comment

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

I recommend to import the fontawesome icons using the Icon Library approach, this way your bundle get smaller. This is what fontawesome suggests:

https://fontawesome.com/how-to-use/javascript-api/setup/importing-icons

Once imported, you can use FontAwesomeIcon with the prop icon='name' to actually use it.



const Header = styled.header`
background-color: #957aa4;
color: white;
`;

const HeaderContainer = styled.div`
min-height: 70px;
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 0 20px 0 20px;
align-items: center;
`;

const LoginButton = styled.button`
border:none;
background-color:grey;
border-radius: 50%;
outline:none;
padding:10px;
margin: 7px;
`;

const SidebarButton = styled.button`
border:none;
background-color:transparent;
border-radius: 50%;
outline:none;
padding: 0.7em;
margin: 1em;
`;


const HeaderInput = styled.input`
border: 0;
border-radius: 5px;
outline: none;
font-size: 0.9em;
padding: 0.4em;
`;

const SpanHeader = styled.span`
margin: 7px;
`;

const ModeControl1 = styled.div`
height: 10px;
background: #5f5d5d;
border-radius: 10px;
width: 35px;
margin: 7px;
`;

const ModeControl2 = styled.div`
height: 20px;
background: white;
border-radius: 10px;
position: relative;
width: 20px;
margin: 7px;
left: -12px;
top: -12px;
`;

const HeaderRightContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
`;


function Navbar() {

return (
<>
Copy link

Choose a reason for hiding this comment

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

Since Header is your root component here, you don't need to use fragments. Also check the comment about moving your styled components outside your main component.

<Header>
<HeaderContainer>
<div>
<SidebarButton>
<FontAwesomeIcon icon={faBars} color="white" size="lg"/>
</SidebarButton>
<HeaderInput placeholder="wizeline" />
</div>
<HeaderRightContainer>
<ModeControl1>
<ModeControl2></ModeControl2>
</ModeControl1>
<SpanHeader>Dark mode</SpanHeader>
<LoginButton>
<FontAwesomeIcon icon={faUser} color="white" size="lg"/>
</LoginButton>
</HeaderRightContainer>
</HeaderContainer>
</Header>
</>
);
}

export default Navbar;
1 change: 1 addition & 0 deletions src/components/Layout/Navbar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Navbar.component';
6 changes: 5 additions & 1 deletion src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ html {
box-sizing: inherit;
}


body {
margin: 0;
}
/* body {
margin: 0;
padding: 0;
text-rendering: optimizeLegibility;
background-image: linear-gradient(
Expand All @@ -31,7 +35,7 @@ body {
transition: background-position 2s ease;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
} */

.separator::before {
content: '•';
Expand Down
35 changes: 17 additions & 18 deletions src/pages/Home/Home.page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, { useRef } from 'react';
import { Link, useHistory } from 'react-router-dom';

import Navbar from "../../components/Layout/Navbar";
import styled from 'styled-components';
import CardVideo from "../../components/Layout/CardVideo";
import {listVideos} from "../../utils/mocks/youtube-videos-mock";
import { useAuth } from '../../providers/Auth';
import './Home.styles.css';

Expand All @@ -15,24 +18,20 @@ function HomePage() {
history.push('/');
}

const CardsContainer = styled.div`
display: flex;
flex-wrap: wrap;
padding: 50px 50px 0 50px;
justify-content: center;
`;

return (
<section className="homepage" ref={sectionRef}>
<h1>Hello stranger!</h1>
{authenticated ? (
<>
<h2>Good to have you back</h2>
<span>
<Link to="/" onClick={deAuthenticate}>
← logout
</Link>
<span className="separator" />
<Link to="/secret">show me something cool →</Link>
</span>
</>
) : (
<Link to="/login">let me in →</Link>
)}
</section>
<>
<Navbar/>
<CardsContainer>
{listVideos.items.map((item)=>{return <CardVideo key={item.etag} item={{item}}/>})}
Copy link

Choose a reason for hiding this comment

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

You could omit the return if you do:

{listVideos.items.map((item) => <CardVideo key={item.etag} item={{item}} />)}

Also, I think you added extra {} to your item prop. That's why you are doing props.item.item in your CardVideo component.

</CardsContainer>
</>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/Login.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function LoginPage() {
function authenticate(event) {
event.preventDefault();
login();
history.push('/secret');
history.push('/');
}

return (
Expand Down
Loading