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

Week 9 – Movie Project – Sofia & Nathalie #48

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
407450c
First commit - Components and rounting created, listing data fetched
sofia32057 Mar 31, 2024
e0acfcb
Update - fetch movie details
sofia32057 Mar 31, 2024
1e73d46
Styling
sofia32057 Mar 31, 2024
ae8f1a6
Fix footer css error
sofia32057 Apr 1, 2024
075f5b2
fixed movie poster size
ohitsnathalie Apr 1, 2024
8ec80fb
Basic styling
sofia32057 Apr 1, 2024
a241654
load more button function
ohitsnathalie Apr 1, 2024
f9731d5
fixing the key
ohitsnathalie Apr 1, 2024
9f55ef8
Basic styling
sofia32057 Apr 1, 2024
43b5ea3
Merge conflicts
sofia32057 Apr 1, 2024
6ed880b
styling on details page
ohitsnathalie Apr 1, 2024
9ae7e62
change header and add favicon
ohitsnathalie Apr 1, 2024
ea6b889
Update - changes to movie fetch
sofia32057 Apr 1, 2024
0418f01
Merge ft-genres
sofia32057 Apr 1, 2024
c7ea087
Bug fix - load more
sofia32057 Apr 1, 2024
3fe9f6a
add back button
ohitsnathalie Apr 3, 2024
6925ed1
button only visible on tablet and desktop
ohitsnathalie Apr 3, 2024
10bd019
Update - genre routed with filtered listing
sofia32057 Apr 3, 2024
a868f01
Bugfix, error import
sofia32057 Apr 3, 2024
291bc20
styling load more button
ohitsnathalie Apr 3, 2024
01b7308
Merge branch 'buttons'
ohitsnathalie Apr 3, 2024
b0cbcd4
changed buttons position and changed API key
ohitsnathalie Apr 3, 2024
81f553f
Update - hide add env and redirect files
sofia32057 Apr 3, 2024
034702f
Merge with nathalies changes
sofia32057 Apr 3, 2024
41fe3ab
added runtime to detail page
ohitsnathalie Apr 3, 2024
5b6e3a2
Update - added genres to details page
sofia32057 Apr 5, 2024
0ec0cd8
Update - genre list wrap mobile
sofia32057 Apr 5, 2024
c0380bc
fixed 404 and added styling to it
ohitsnathalie Apr 5, 2024
6d17b9a
Merge branch 'buttons'
ohitsnathalie Apr 5, 2024
b9fb27a
change README
ohitsnathalie Apr 6, 2024
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DBAPI_KEY = 5f524441926a384bdad27fc1fd156e93
23 changes: 12 additions & 11 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: "18.2" } },
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
"react/prop-types": "off",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
}
};
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ npm i && code . && npm run dev

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?

#### Next

- Add disclamer: "This [website, program, service, application, product] uses TMDB and the TMDB APIs but is not endorsed, certified, or otherwise approved by TMDB."

### 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.
[![Netlify Status](https://api.netlify.com/api/v1/badges/832d0052-da1e-49ae-9040-74ff2906a5c8/deploy-status)](https://app.netlify.com/sites/nathalies-sofias-project-movies/deploys)
https://nathalies-sofias-project-movies.netlify.app/

## Instructions

Expand Down
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Movie Site Project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/popcorn.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nathalie's & Sofia's Movie Site Project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added public/popcorn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

42 changes: 40 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
import { BrowserRouter, Routes, Route } from "react-router-dom"
import { Footer } from "./components/footer/Footer"
import { Header } from "./components/header/Header"
import { Details } from "./components/details/Details"
import { Listing } from "./components/listing/Listing"
import { NotFound } from "./components/404/NotFound"
import { Genres } from "./components/genres/Genres"

export const App = () => {
return <div>Find me in src/app.jsx!</div>;
};
return (
<>
<BrowserRouter>
<Header />
<main>
<Routes>
{/* Conditional that makes the "page content" switch between components, depending on the URL*/}
<Route
path="/"
element={<Listing />}
errorElement={<NotFound />}
/>
<Route
path="/movies/:slug/*"
element={<Details />}
errorElement={<NotFound />}
/>
<Route
path="/genre/:genreId/"
element={<Genres />}
/>
<Route
path="*"
element={<NotFound />}
/>
</Routes>
</main>
<Footer />
</BrowserRouter>
</>
)
}
Binary file added src/assets/RubikScribble-Regular.ttf
Binary file not shown.
Binary file added src/assets/left-arrows-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added src/components/404/NotFound.css
Empty file.
13 changes: 13 additions & 0 deletions src/components/404/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useRouteError } from "react-router-dom"
import "./NotFound.css"

export const NotFound = () => {
const error = useRouteError()
console.error(error)
return (
<div>
<h1>Oups!</h1>
<p>{error.statusText || error.message}</p>
</div>
)
}
139 changes: 139 additions & 0 deletions src/components/details/Details.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
.details-container {
height: 100svh;
padding: 5%;
color: white;
display: flex;
flex-wrap: wrap;
/* align-items: flex-end;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused code

align-content: flex-end; */
justify-items: center;
}

.back-btn-wrapper {
align-self: flex-start;
position: absolute;
top: 7%;
display: none;
}

.back-button {
width: 35px;
height: 35px;
filter: drop-shadow(0 0 0.4rem black);

Choose a reason for hiding this comment

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

this shadow is a bit wonky -(square shadow on a round object) maybe use a svg instead to avoid this? :)

}

.poster {
object-fit: cover;
height: 100%;
max-width: 200px;
width: auto;
border: 6px solid white;
box-shadow: var(--box-shadow);
margin-left: 16px;
position: relative;
}

.details {
width: 100%;
background: radial-gradient(rgba(0, 0, 0, 0) 100%, rgb(0, 0, 0) 70%);
display: flex;
flex-wrap: wrap;
align-items: flex-start;
align-self: flex-start;
justify-items: center;
gap: 0.5rem;
margin-bottom: 30px;
}

.summary {
padding: 1rem 1rem 0 1rem;

Choose a reason for hiding this comment

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

maybe add some more contrast here as well to improve readability?

display: flex;
flex-direction: column;
gap: 1rem;
}

.title {
text-shadow: var(--text-shadow);
font-size: 28px;
word-wrap: break-word;
}

.desc {
font-size: 16px;
}

.rank-time-container {
display: flex;
gap: 2rem;
}

.ranking,
.runtime {
background-color: rgba(0, 0, 0, 0.4);

Choose a reason for hiding this comment

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

nice with the dark background so its easier to read :)

padding: 0.2rem;
width: fit-content;
color: rgba(255, 255, 255, 0.869);
font-weight: 600;
font-size: 0.875rem;
border-radius: 3px;
font-style: italic;
}

.ranking::before {
content: "⭐️ ";
display: inline;
}

.ranking::after {
content: " / 10";
display: inline;
}

@media all and (min-width: 668px) {
.details-container {
flex-direction: row;
align-content: flex-end;
}

.details {
align-items: flex-end;
align-content: flex-end;
}

.back-btn-wrapper {
left: 20px;
display: block;
}

.summary {
width: 55%;
}

.poster {
max-width: 245px;
}
.title {
font-size: 38px;
}

.desc {
font-size: 18px;
}
}

@media all and (min-width: 1028px) {
.poster {
max-width: 295px;
}
.summary {
width: 65%;
}

.title {
font-size: 3rem;
}

.desc {
font-size: 20px;
}
}
78 changes: 78 additions & 0 deletions src/components/details/Details.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Link, useParams } from "react-router-dom"
import "./Details.css"
import { useEffect, useState } from "react"
import backButton from "../../assets/left-arrows-white.png"
import { GenreList } from "../genreList/GenreList"

export const Details = () => {
const movie = useParams()
const [results, setResults] = useState()
const API_KEY = import.meta.env.VITE_DBAPI_KEY

Choose a reason for hiding this comment

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

nice hiding that key on the client side :)

const API_LANG = "en-US"
const POSTER_URL = "https://image.tmdb.org/t/p"

useEffect(() => {
const fetchDetails = async () => {
try {
const response = await fetch(
`https://api.themoviedb.org/3/movie/${movie.slug}?api_key=${API_KEY}&language=${API_LANG}`
)
if (!response.ok) {
throw Error("Something wrong with the fetch")
}
const data = await response.json()
setResults(data)
} catch (error) {
console.error("Error", error)
setResults([])
}
}

fetchDetails()
}, [])
Comment on lines +14 to +32
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also be written as:

const fetchDetails = async () => {
    try {
      const response = await fetch(
        `https://api.themoviedb.org/3/movie/${movie.slug}?api_key=${API_KEY}&language=${API_LANG}`
      )
      if (!response.ok) {
        throw Error("Something wrong with the fetch")
      }
      const data = await response.json()
      setResults(data)
    } catch (error) {
      console.error("Error", error)
      setResults([])
    }
  }
  
useEffect(() => {
  fetchDetails()
}, [])


return (
<>
{results && (
<section
className="details-container"
style={{
background: `linear-gradient(rgba(0, 0, 0, 0) 20%, rgb(0, 0, 0) 100%), url(${POSTER_URL}/original${results.backdrop_path}) center/cover no-repeat`,
}}>
<div className="details">
<div className="back-btn-wrapper">
<Link to={"/"}>
<img
className="back-button"

Choose a reason for hiding this comment

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

stick to either this one or the other one. this seemes a bit more styled so maybe just keep this one?

src={backButton}
alt="white arrow button pointing left"
/>
</Link>
</div>
<img
className="poster"
src={`${POSTER_URL}/w500${results.poster_path}`}
alt={results.title}
/>
<div className="summary">
<h1 className="title">{results.title}</h1>
<div className="rank-time-container">
<p className="ranking">
{Math.round(results.vote_average * 100) / 100}
</p>
<p className="runtime">{results.runtime} minutes</p>
</div>
<p className="desc">{results.overview}</p>
<div className="genre-container">
<GenreList
genreArray={results.genres}
n={false}
Comment on lines +67 to +69
Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh, nice! ⭐

/>
</div>
</div>
</div>
</section>
)}
</>
)
}
3 changes: 3 additions & 0 deletions src/components/error/Error.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.error-msg {
padding: 2rem;
}
5 changes: 5 additions & 0 deletions src/components/error/Error.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "./Error.css"

export const Error = ({ m }) => {
return <div className="error-msg">{m}</div>
}
Loading