Skip to content

Commit

Permalink
main layout, components, styles
Browse files Browse the repository at this point in the history
  • Loading branch information
murelain committed Mar 19, 2021
1 parent 5654ce6 commit 8539648
Show file tree
Hide file tree
Showing 17 changed files with 16,652 additions and 154 deletions.
16,048 changes: 16,048 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.3",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -13,6 +14,7 @@
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.3",
"styled-components": "^5.2.1",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
Expand All @@ -39,5 +41,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/styled-components": "^5.1.9"
}
}
6 changes: 6 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
html,
body,
.App {
height: 100%;
}

.App {
text-align: center;
}
Expand Down
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import Layout from './Layout';

function App() {
Expand Down
41 changes: 32 additions & 9 deletions src/ContentLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
import React, { FC } from 'react';
import Filters from '../components/Filters';
import Menu from '../components/Menu';
import MoviesList from '../components/MovieList';
import Sort from '../components/Menu';
import MoviesList, { MovieInterface } from '../components/MovieList';
import styled from "styled-components";

export const ContentStyled = styled.div`
padding: 30px;

This comment has been minimized.

Copy link
@i9or

i9or Apr 12, 2021

Consider adding prettier to the project. Code formatting is off in some places.

display: flex;
flex-direction: column;
background: #484848;
flex-grow: 1;
`;

const ContentLayout: FC = () => {
export const ContentHeaderStyled = styled.div`
display: flex;
justify-content: space-between;
width: 100%;
border-bottom: 1px solid;
align-items: flex-end;
`;


interface Content {
moviesList: MovieInterface[];
}

const ContentLayout: FC<Content> = ({ moviesList }) => {

return (
<>
<div>
<Menu />
<ContentStyled>
<ContentHeaderStyled>
<Filters />
</div>
<MoviesList />
</>);
<Sort />
</ContentHeaderStyled>
<MoviesList sortedMovies={moviesList} />
</ContentStyled>);
}

export default ContentLayout;
15 changes: 14 additions & 1 deletion src/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { Button, TextField } from '@material-ui/core';
import React, { FC } from 'react';
import { HeaderStyled, SearchContainerStyled, HeaderTopStyled, TextFieldStyled } from './styles';

const Header: FC = () => {

return (<>header</>);
return (
<HeaderStyled>
<HeaderTopStyled>
<img width="180" src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Netflix_2014_logo.svg/1200px-Netflix_2014_logo.svg.png" />
<Button color="primary" variant="contained">Add movie</Button>
</HeaderTopStyled>
<SearchContainerStyled>
<TextFieldStyled id="standard-basic" variant="filled" color="secondary" />
<Button color="secondary" variant="contained">Search</Button>
</SearchContainerStyled>
</HeaderStyled>
);
}

export default Header;
28 changes: 28 additions & 0 deletions src/Header/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styled from "styled-components";
import { TextField } from "@material-ui/core";
export const HeaderStyled = styled.div`
padding: 30px;
min-height: 200px;
display: flex;
flex-direction: column;
justify-content: space-between;
background-image: url("https://bramptonist.com/wp-content/uploads/2018/06/netflix-image.jpg");
`;

export const SearchContainerStyled = styled.div`
display: flex;
justify-content: center;
width: 80%;
align-self: center;
`;

export const HeaderTopStyled = styled.div`
display: flex;
justify-content: space-between;
`;

export const TextFieldStyled = styled(TextField)`
background: #655757a3;
flex-grow: 1;
margin-right: 15px !important;
`;
10 changes: 5 additions & 5 deletions src/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { FC } from 'react';
import { MovieInterface } from '../components/MovieList';
import ContentLayout from '../ContentLayout';
import Header from '../Header';

import { MOVIES } from '../mock-data';


const Layout: FC = () => {

//const movies =
const movies = MOVIES as unknown as MovieInterface[];

This comment has been minimized.

Copy link
@i9or

i9or Apr 12, 2021

I guess, you actually don't need double type casting here.


return (
<>
layout
{/* <Header />
<ContentLayout /> */}
<Header />
<ContentLayout moviesList={movies} />
</>
);
}
Expand Down
13 changes: 4 additions & 9 deletions src/MovieCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import React, { FC } from 'react';
import { MovieInterface } from '../components/MovieList';

const MovieCard: FC<MovieCardInterface> = ({ title, description }) => {
const MovieCard: FC<{ movie: MovieInterface }> = ({ movie }) => {

return (
<div className="MovieCard">
<h3>{title}</h3>
<h3>{description}</h3>
<h3>{movie.title}</h3>
<img width="200px" height="350px" src={movie.posterUrl} />
</div>
);
}

interface MovieCardInterface {
title: string,
description: string,
coverUrl: string,
}


export default MovieCard;

19 changes: 15 additions & 4 deletions src/components/Filters/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@

import Link from '@material-ui/core/Link';
import React, { FC } from 'react';
import styled from 'styled-components';

const StyledFilters = styled.div`
display: flex;
`;

import './App.css';
const FilterLink = styled(Link)`
padding: 6px 12px;
`;

const Filters: FC = () => {
const filterOptions = ['all', 'documentary', 'comedy', 'horror', 'crime']

return (
<>

</>
<StyledFilters>
{filterOptions.map(filter => (
<FilterLink href="#" color="textSecondary"> {filter} </FilterLink>
))}
</StyledFilters>
);
}

Expand Down
32 changes: 25 additions & 7 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
import React, { FC } from 'react';

import { FormControl, InputLabel, Link, MenuItem, Select } from '@material-ui/core';
import React, { FC } from 'react';
import styled from 'styled-components';

import './App.css';
const StyledSelect = styled(Select)`
min-width: 180px;
align-items: flex-end;
border-bottom: 1px solid;
`;

const Sort: FC = () => {

const sortOptions = [{
key: 'byDate',
title: 'Release date'
}]

return (
<div>
<FormControl>
<InputLabel id="demo-simple-select-label">Sort By</InputLabel>
<StyledSelect color="secondary"

const Menu: FC = () => {
id="demo-simple-select"

return (
<>
>
{sortOptions.map(menu => (<MenuItem value={menu.key} key={menu.key}>{menu.title}</MenuItem>))}

</>
</StyledSelect>
</FormControl>
</div>
);
}

export default Menu;
export default Sort;
37 changes: 34 additions & 3 deletions src/components/MovieList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
import React, { FC } from 'react';
import styled from 'styled-components';
import MovieCard from '../../MovieCard';


const MoviesList: FC = () => {


const StyledMoviesList = styled.div`
display: flex;
flex-wrap: wrap;
`;


const MovieCardContainerStyled = styled.div`
padding: 15px;
`;
export interface MovieInterface {

This comment has been minimized.

Copy link
@i9or

i9or Apr 12, 2021

Just a suggestion, consider not adding Interface suffix to the interface name (or I prefix, or any sort of indication that this is an interface). While there are no actual rules for that, here's good comment clarifying why one should reconsider such naming practice: microsoft/TypeScript-Handbook#121 (comment)

On the other hand naming is hard so feel free to ignore my comment 😅

title: string,
description: string,
posterUrl: string,
id: string,
genres?: ["Action", "Comedy", "Crime"]
releaseDate?: "2018-02-28",
}

interface MoviesListInterface {

This comment has been minimized.

Copy link
@i9or

i9or Apr 12, 2021

Might be better to name it MovieListProps

sortedMovies: MovieInterface[];
}

const MoviesList: FC<MoviesListInterface> = ({ sortedMovies }) => {

return (
<>
<StyledMoviesList>

{sortedMovies.map(movie => (
<MovieCardContainerStyled>
<MovieCard movie={movie}></MovieCard>
</MovieCardContainerStyled>))}

</>
</StyledMoviesList>
);
}

Expand Down
19 changes: 16 additions & 3 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

html,
body,
#root {
height: 100%;
}

.App {
display: flex;
flex-direction: column;

height: 100%;
}
Loading

0 comments on commit 8539648

Please sign in to comment.