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

https://Pavlo-lab-max-Kopalko.github.io/react_movies-list-js/ #1320

Open
wants to merge 2 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
91 changes: 3 additions & 88 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,98 +1,13 @@
/* eslint-disable max-len */

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

export const App = () => (
<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>
<MovieList movies={movies} />
</div>

<div className="sidebar" data-cy="Sidebar">
Expand Down
13 changes: 2 additions & 11 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ iframe {
min-height: 100vh;
}

.page-content {
padding: 20px;
}

.sidebar {
padding: 20px;
border-left: 1px solid lightgray;
}

.movies {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
.page-content {
padding: 20px;
}

.card-image img {
object-fit: contain;
}
36 changes: 35 additions & 1 deletion src/components/MovieCard/MovieCard.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
import './MovieCard.scss';

export const MovieCard = () => <>Put the card here</>;
export const MovieCard = ({ movie }) => {
return (
<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>
</div>

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

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

<a href={movie.imdbUrl} data-cy="MovieLink">
IMDB
</a>
</div>
</div>
);
};
4 changes: 3 additions & 1 deletion src/components/MovieCard/MovieCard.scss
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// add styles here
.card-image img {
object-fit: contain;
}
15 changes: 14 additions & 1 deletion src/components/MovieList/MovieList.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import { MovieCard } from '../MovieCard/MovieCard';
import './MovieList.scss';

export const MovieList = () => <>Put the list here</>;
export const MovieList = ({ movies }) => {
if (movies.length === 0) {
return undefined;
}

return (
<div className="movies">
{movies.map(movie => (
<MovieCard movie={movie} key={movie.imdbId} />
))}
</div>
);
};
5 changes: 5 additions & 0 deletions src/components/MovieList/MovieList.scss
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
// add styles here
.movies {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
}
8 changes: 7 additions & 1 deletion src/components/MovieList/MovieList.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ describe('MoviesList component', () => {
it('should render a card per each movie', () => {
mount(<MovieList movies={movies} />);

cy.getByDataCy('Movie').should('have.length', 5);
// eslint-disable-next-line no-unused-expressions
cy.getByDataCy('Movie').should('have.length', 5).only;
});

it('should put movies in correct order', () => {
mount(<MovieList movies={movies} />);

cy.getByDataCy('MovieTitle').eq(0).should('have.text', 'Inception');
cy.getByDataCy('MovieTitle').eq(1).should('have.text', 'Love Actually');
cy.getByDataCy('MovieTitle')
.eq(2)
.should('have.text', 'The Day After Tomorrow');
cy.getByDataCy('MovieTitle').eq(3).should('have.text', 'Rogue One');
cy.getByDataCy('MovieTitle').eq(4).should('have.text', 'The Holiday');
});

Expand Down
Loading