Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React movie list #1935

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@mate-academy/eslint-config-react-typescript": "latest",
"@mate-academy/scripts": "^1.7.8",
"@mate-academy/scripts": "^1.7.9",
"@mate-academy/students-ts-config": "latest",
"@mate-academy/stylelint-config": "latest",
"@types/node": "^16.18.80",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"cypress": "^12.17.4",
"cypress": "^13.7.0",
"eslint": "^7.32.0",
"eslint-plugin-cypress": "^2.11.2",
"gh-pages": "^6.1.1",
Expand Down
91 changes: 3 additions & 88 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,13 @@
import React from 'react';

import './App.scss';
// import moviesFromServer from './api/movies.json';
import moviesFromServer from './api/movies.json';
import { MoviesList } from './components/MoviesList';

export const App: React.FC = () => (
<div className="page">
<div className="page-content">
<div className="movies">
<div className="card" data-cy="Movie">
<div className="card-image">
<figure className="image is-4by3">
<img
data-cy="MovieImage"
src="https://m.media-amazon.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg"
alt="Film logo"
/>
</figure>
</div>

<div className="card-content">
<div className="media">
<div className="media-left">
<figure className="image is-48x48">
<img src="images/imdb-logo.jpeg" alt="imdb" />
</figure>
</div>

<div className="media-content">
<p className="title is-8" data-cy="MovieTitle">
Inception
</p>
</div>
</div>

<div className="content">
<p data-cy="MovieDescription">
Follows the lives of eight very different couples in dealing
with their love lives in various loosely interrelated tales all
set during a frantic month before Christmas in London, England.
</p>

<a
href="https://www.imdb.com/title/tt1375666"
data-cy="MovieLink"
>
IMDB
</a>
</div>
</div>
</div>

<div className="card" data-cy="Movie">
<div className="card-image">
<figure className="image is-4by3">
<img
data-cy="MovieImage"
src="https://m.media-amazon.com/images/M/MV5BMTY4NjQ5NDc0Nl5BMl5BanBnXkFtZTYwNjk5NDM3._V1_.jpg"
alt="Film logo"
/>
</figure>
</div>

<div className="card-content">
<div className="media">
<div className="media-left">
<figure className="image is-48x48">
<img src="images/imdb-logo.jpeg" alt="imdb" />
</figure>
</div>

<div className="media-content">
<p className="title is-8" data-cy="MovieTitle">
Love Actually
</p>
</div>
</div>

<div className="content">
<p data-cy="MovieDescription">
A thief who steals corporate secrets through the use of
dream-sharing technology is given the inverse task of planting
an idea into the mind of a C.E.O.
</p>

<a
href="https://www.imdb.com/title/tt0314331"
data-cy="MovieLink"
>
IMDB
</a>
</div>
</div>
</div>
</div>
<MoviesList movies={moviesFromServer} />
</div>

<div className="sidebar" data-cy="Sidebar">
Expand Down
40 changes: 39 additions & 1 deletion src/components/MovieCard/MovieCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
/* eslint-disable max-len */
import React from 'react';

import './MovieCard.scss';
import { Movie } from '../../types/Movie';

export const MovieCard: React.FC = () => <>Put the card here</>;
type Props = {
movie: Movie;
};

export const MovieCard: React.FC<Props> = ({ movie }) => (
<div className="card" data-cy="Movie">
<div className="card-image">
<figure className="image is-4by3">
<img data-cy="MovieImage" src={movie.imgUrl} alt="Film logo" />
</figure>
</div>

<div className="card-content">
<div className="media">
<div className="media-left">
<figure className="image is-48x48">
<img src="images/imdb-logo.jpeg" alt="imdb" />
</figure>
</div>

<div className="media-content">
<p className="title is-8" data-cy="MovieTitle">
{movie.title}
</p>
</div>
</div>

<div className="content">
<p data-cy="MovieDescription">{movie.description}</p>

<a href={movie.imdbUrl} data-cy="MovieLink">
IMDB
</a>
</div>
</div>
</div>
);
15 changes: 14 additions & 1 deletion src/components/MoviesList/MoviesList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
/* eslint-disable max-len */
import React from 'react';
import './MoviesList.scss';
import { Movie } from '../../types/Movie';
import { MovieCard } from '../MovieCard';

export const MoviesList: React.FC = () => <>Put the list here</>;
type Props = {
movies: Movie[];
};

export const MoviesList: React.FC<Props> = ({ movies }) => (
<div className="movies">
{movies.map(movie => (
<MovieCard movie={movie} key={movie.imdbId} />
))}
</div>
);
6 changes: 4 additions & 2 deletions src/types/Movie.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export interface Movie {
title: string;

// add all the other field
description: string;
imgUrl: string;
imdbUrl: string;
imdbId: string;
}
Loading