Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkadiuszx committed Mar 5, 2024
1 parent 3dd289b commit 41be77c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 93 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ You are given movies loaded from the API and initial markup. Your task is to:
- Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline).
- Use the [React TypeScript cheat sheet](https://mate-academy.github.io/fe-program/js/extra/react-typescript).
- Open one more terminal and run tests with `npm test` to ensure your solution is correct.
- Replace `<your_account>` with your Github username in the [DEMO LINK](https://<your_account>.github.io/react_movies-list/) and add it to the PR description.
- Replace `<your_account>` with your Github username in the [DEMO LINK](https://Arkadiuszx.github.io/react_movies-list/) and add it to the PR description.
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;
}

0 comments on commit 41be77c

Please sign in to comment.