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

. #327

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

. #327

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2152a25
.
AnnaElvine Mar 29, 2023
c3556d2
heeej
AnnaElvine Mar 29, 2023
8555b85
haha
AnnaElvine Mar 29, 2023
fbf8ea9
Update README.md
AnnaElvine Mar 29, 2023
a95c733
a
AnnaElvine Mar 29, 2023
e611583
Merge branch 'master' of https://github.com/AnnaElvine/project-movies
AnnaElvine Mar 29, 2023
e64ed0b
added export default
Mar 29, 2023
6654702
changed the export import
Mar 29, 2023
7a71dc8
fix errors
Mar 29, 2023
af8d429
got the posters to show in browser
Mar 29, 2023
1a29334
fixed small error
Mar 29, 2023
5d126dc
added display flex in CSS
Mar 30, 2023
390b578
added some styling
Mar 30, 2023
3b7e8a8
changed img width
Mar 30, 2023
bc64bfc
css
AnnaElvine Mar 31, 2023
0c9792a
.
AnnaElvine Mar 31, 2023
adba813
styled the page, added a backbutton
AnnaElvine Mar 31, 2023
17f62fb
fixed back button
AnnaElvine Mar 31, 2023
fdb1ce2
fixed some stuff :)
AnnaElvine Mar 31, 2023
d5bb1ad
<
AnnaElvine Mar 31, 2023
c697c22
intro
AnnaElvine Mar 31, 2023
b60f68d
loading intro
AnnaElvine Apr 1, 2023
39441e5
change cursor, styling, intro
AnnaElvine Apr 1, 2023
7b1ca64
drop down menu + header
AnnaElvine Apr 1, 2023
058a4b6
.
AnnaElvine Apr 1, 2023
0b48994
netlify fix
AnnaElvine Apr 1, 2023
3aff207
fixed rating, the dropdown menu does not work yet
AnnaElvine Apr 1, 2023
5100863
.
AnnaElvine Apr 1, 2023
276a07f
fixed intro
AnnaElvine Apr 3, 2023
d2f072e
Co-authored-by: Matilda Brunemalm <[email protected]>
AnnaElvine Apr 3, 2023
60cea3a
.
AnnaElvine Apr 3, 2023
485c076
all done
AnnaElvine Apr 3, 2023
7e136cc
.
AnnaElvine Apr 3, 2023
21f746d
Update README.md
AnnaElvine Apr 3, 2023
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
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Project Movies
# Project Movies 🍿🎥

Replace this readme with your own information about your project.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
We did a movie page using react.

## The problem

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
We had some problem with the intro and to upload it on netlify!

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
https://annandreas-popular-movies.netlify.app/
63 changes: 62 additions & 1 deletion code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.10.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1 change: 1 addition & 0 deletions code/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added code/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions code/public/favicoon.ico
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link rel="icon" type="image/png" href="%PUBLIC_URL%/favicoon.ico" />
4 changes: 1 addition & 3 deletions code/public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand All @@ -13,7 +12,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Technigo React App</title>
<title>Popular Movies</title>
</head>

<body>
Expand All @@ -30,5 +29,4 @@
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</html>
23 changes: 19 additions & 4 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import React from 'react';
import React from 'react'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import MovieList from 'components/MovieList'
import MovieDetails from 'components/MovieDetails'
import NotFound from 'components/NotFound'

export const App = () => {
return (
<div>
Find me in src/app.js!
</div>
<BrowserRouter>
<Routes>
<Route path="/" element={<MovieList />} />
<Route path="/details/:id" element={<MovieDetails />} />
<Route path="/404" element={<NotFound />} />
<Route path="*" element={<Navigate to="404" replace />} />
</Routes>
</BrowserRouter>

);
}

export default App;
/* BrowserRouter= Wrapper for everything / main wrapper for the whole wrap */
/* Route= Wrapper for every component */
/* Route path= Path to a single component */
29 changes: 29 additions & 0 deletions code/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
/* import React from 'react';

const Header = () => {
/* const [category, setCategory] = useState('popular'); */

/* return (
<div className="header-container">
<div className="dropdown">
<button type="button">Menu</button>
<div className="dropdown-content">
<a href="#">Latest</a>
<a href="#">Series</a>
<a href="#">Upcoming</a>
</div>
</div>
</div>
)
}

export default Header;
*/
/* <label htmlFor="category">Change category: </label> <select id="category" onChange={(event) =>
setCategory(event.target.value)} value={category}>
<option value="popular">Popular</option>
<option value="now_playing">Now Playing</option>
<option value="upcoming">Upcoming</option>
<option value="top_rated">Top Rated</option>
</select> */
13 changes: 13 additions & 0 deletions code/src/components/Intro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'

const Popcorn = () => (

Choose a reason for hiding this comment

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

Try to be consistent with the naming, so that the main function and file are named the same

<div className="loading-movies">
<span className="loading-intro" role="img" aria-label="loading">

<img src="https://payload.cargocollective.com/1/1/44701/13320134/New-Yorker-Movies-GIFWEB.gif" alt="popcorngif" className="center" />
<h5>Get your snacks ready</h5>
</span>
</div>
)

export default Popcorn
67 changes: 67 additions & 0 deletions code/src/components/MovieDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */
import React, { useState, useEffect } from 'react'
import { useParams, useNavigate } from 'react-router-dom'
import NotFound from 'components/NotFound'

/* PAGE 2 */
const MovieDetails = () => {
const [details, setDetails] = useState([]);
const navigate = useNavigate();
const { id } = useParams()
const onBackButtonClick = () => {
navigate(-1);
}

const FetchDetails = () => {
fetch(`https://api.themoviedb.org/3/movie/${id}?api_key=e865fc7d6c1eaa875454193ac1851471&language=en-US`)
.then((response) => response.json())
.then((data) => setDetails(data))
.catch((error) => {
console.log(error)
if (error) {
return (<NotFound />
)
}
})
}
// eslint-disable-next-line no-unused-vars
const handleBackButton = (event) => {
if (event.KeyCode === 13) {

Choose a reason for hiding this comment

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

What does this mean? Should I be able to press Enter on the backbutton?

onBackButtonClick();
}
};
useEffect(() => {
FetchDetails()
})

Choose a reason for hiding this comment

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

How come you did FetchDetails as a function and not put it straight in UseEffect?


return (
<section className="detail-page">
<div
className="background"
style={{
backgroundImage: `url(http://image.tmdb.org/t/p/original${details.backdrop_path})`
}}>
<div className="backbutton">
<div type="button" className="button" onClick={onBackButtonClick}>
<span />
<span />
<span />
</div>
</div>
<div className="movie-details">
<img src={`http://image.tmdb.org/t/p/w342${details.poster_path}`} alt={details.title} />
</div>
<div className="details-page-2">
<h3>{details.title} <span className="rating">⭐️{Math.round(details.vote_average * 10) / 10}</span></h3>
<p>{details.overview}</p>
</div>
</div>
</section>
);
}

export default MovieDetails;

/* To round rating number to one decimal */
/* const roundedNumber = Math.round(movieDetails.vote_average * 10) / 10 */
51 changes: 51 additions & 0 deletions code/src/components/MovieList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable no-shadow */
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import Popcorn from './Intro';
/* import Header from './Header'; */
/* STARTPAGE */
const MovieList = () => {
const [list, setList] = useState([]);
const [loading, setLoading] = useState(false);

/* Fetch function that allows us to get the movie titles, images from API */
const FetchMovies = () => {
fetch('https://api.themoviedb.org/3/movie/popular?api_key=e865fc7d6c1eaa875454193ac1851471&language=en-US&page=1')
.then((response) => response.json())
.then((data) => {
setList(data.results)
})
}
/* A call back function - this useEffect hook awakens the FetchMovies function above */
useEffect(() => {
FetchMovies()
setLoading(true);
setTimeout(() => setLoading(false), 2000)
}, [])

/* This return shows the img, titles, rdate & the id on our HTML page */
return (
<section className="startPage">
{loading ? (<Popcorn />) : (

Choose a reason for hiding this comment

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

Love the loader!

<>
{/* <Header setList={setList} /> */}
<div className="movie-container">
{list.map((movie) => (
<article className="movie-wrapper" key={movie.id}>
<Link key={movie.id} to={`/details/${movie.id}`}>
<img src={`https://image.tmdb.org/t/p/w342${movie.poster_path}`} alt={movie.title} />
<div className="details">
<h1>{movie.title}</h1>
<p>Released {movie.release_date}</p>
</div>
</Link>
</article>
))}
</div>
</>
)}
</section>
)
}

export default MovieList;
15 changes: 15 additions & 0 deletions code/src/components/NotFound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';

const NotFound = () => {
const navigate = useNavigate();
const onHomeButtonClick = () => {
navigate('/');
}
return (
<div>
<p>Page not found</p>
<button type="button" onClick={onHomeButtonClick}>Return to homepage</button>
</div>);
}
export default NotFound;
Loading