diff --git a/.env b/.env new file mode 100644 index 00000000..d6a571f6 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +VITE_API_KEY=0d7613c1b95dbc61f3dd491c8f802475 + + +# import.meta.env.VITE_API_KEY diff --git a/README.md b/README.md index f768e33f..fdd883cd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,70 @@ -# React + Vite +## Unit Assignment: Flixster -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +Submitted by: **MAYA ODY-AJIKE** -Currently, two official plugins are available: +Estimated time spent: **#>=45** hours spent in total -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh +Deployed Application (optional): [Flixster Deployed Site](https://flixster-starter-c8r7.onrender.com/) + +### Application Features + +#### CORE FEATURES + + +- [x] **Display Movies** + - [x] Users can view a list of current movies from The Movie Database API. + - [x] For each movie displayed, users can see its title, poster image, and votes. + - [x] Users can load more current movies by clicking a button at the bottom of the list (page should not be reloaded). +- [x] **Search Functionality** + - [x] Users can search for movies and view the results in a grid. + - [x] Users can clear results and view previous current movies displayed. +- [x] **Accessibility Features** + - [x] Website implements accessibility features (semantic HTML, color contrast, font sizing, alt text for images). +- [x] **Responsive Design** + - [x] Website implements responsive web design. +- [x] **Movie Details** + - [x] Users can view more details about a movie in a popup, such as runtime in minutes, backdrop poster, release date, genres, and/or an overview. +- [x] **Sorting Options** + - [x] Users can click on a filter by drop down to sort product by type (alphabetic, release date, rating). +- [x] **Layout** + - [x] Website displays header, banner, search, movie grid, about, contact, and footer section. + +#### STRETCH FEATURES + +- [x] **Deployment** + - [x] Website is deployed via Render. +- [x] **Embedded Movie Trailers** + - [x] Within the popup displaying a movie's details, users can play the movie trailer. +- [x] **Watched Checkbox** + - [x] For each movie displayed, users can mark the movie as watched. +- [x] **Favorite Button** + - [x] For each movie displayed, users can favorite the movie. +- [x] **Sidebar** + - [x] Users can open a sidebar + - [x] The sidebar displays the user's favorited and watched movies + +### Walkthrough Video +[(https://www.youtube.com/watch?v=-rxltp0H8b4)] + +### Reflection + +* Did the topics discussed in your labs prepare you to complete the assignment? Be specific, which features in your weekly assignment did you feel unprepared to complete? + +I felt unprepared handling the useState and useEffects, passing props from Parent to Child and Child back to Parents was also difficult for me. I also felt unprepared to access the data from the API calls at first, but after doing it multiple times I was able to get the hang of it. + +* If you had more time, what would you have done differently? Would you have added additional features? Changed the way your project responded to a particular event, etc. + +If I had more time I would have done more CSS designs and made my app a little more responsive. I would have also styled my side bar a lot better. + +* Reflect on your project demo, what went well? Were there things that maybe didn't go as planned? Did you notice something that your peer did that you would like to try next time? + +I think my demo went well, My peers did a lot of cool designs and animations and I would like to try some more of that next time. + +### Open-source libraries used + +- Add any links to open-source libraries used in your project. + +### Shout out + +Give a shout out to somebody from your cohort that especially helped you during your project. This can be a fellow peer, instructor, TA, mentor, etc. +Shoutout to Saja, Marvin, Carter, George, Makayla, Thomas, Jackie, and my manager Melissa everyone overall was super helpful! diff --git a/package-lock.json b/package-lock.json index 92a683d2..6db0c557 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,12 @@ "name": "flixster", "version": "0.0.0", "dependencies": { + "@fortawesome/fontawesome-free": "^6.5.2", + "date-fns": "^3.6.0", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-icons": "^5.2.1", + "react-router-dom": "^6.23.1" }, "devDependencies": { "@types/react": "^18.2.66", @@ -19,7 +23,7 @@ "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", - "vite": "^5.2.0" + "vite": "^5.2.13" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -811,6 +815,15 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fortawesome/fontawesome-free": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.2.tgz", + "integrity": "sha512-hRILoInAx8GNT5IMkrtIt9blOdrqHOnPBH+k70aWUAqPZPgopb9G5EQJFpaBx/S8zp2fC+mPW349Bziuk1o28Q==", + "hasInstallScript": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -927,6 +940,14 @@ "node": ">= 8" } }, + "node_modules/@remix-run/router": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.1.tgz", + "integrity": "sha512-es2g3dq6Nb07iFxGk5GuHN20RwBZOsuDQN7izWIisUcv9r+d2C5jQxqmgkdebXgReWfiyUabcki6Fg77mSNrig==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.13.2", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.13.2.tgz", @@ -1645,6 +1666,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/date-fns": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -3516,6 +3546,14 @@ "react": "^18.2.0" } }, + "node_modules/react-icons": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", + "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -3531,6 +3569,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.23.1", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.23.1.tgz", + "integrity": "sha512-fzcOaRF69uvqbbM7OhvQyBTFDVrrGlsFdS3AL+1KfIBtGETibHzi3FkoTRyiDJnWNc2VxrfvR+657ROHjaNjqQ==", + "dependencies": { + "@remix-run/router": "1.16.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.23.1", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.23.1.tgz", + "integrity": "sha512-utP+K+aSTtEdbWpC+4gxhdlPFwuEfDKq8ZrPFU65bbRJY+l706qjR7yaidBpo3MSeA/fzwbXWbKBI6ftOnP3OQ==", + "dependencies": { + "@remix-run/router": "1.16.1", + "react-router": "6.23.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz", @@ -4100,9 +4168,9 @@ } }, "node_modules/vite": { - "version": "5.2.7", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.7.tgz", - "integrity": "sha512-k14PWOKLI6pMaSzAuGtT+Cf0YmIx12z9YGon39onaJNy8DLBfBJrzg9FQEmkAM5lpHBZs9wksWAsyF/HkpEwJA==", + "version": "5.2.13", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.13.tgz", + "integrity": "sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==", "dev": true, "dependencies": { "esbuild": "^0.20.1", diff --git a/package.json b/package.json index eded5715..91a3beff 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,12 @@ "preview": "vite preview" }, "dependencies": { + "@fortawesome/fontawesome-free": "^6.5.2", + "date-fns": "^3.6.0", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-icons": "^5.2.1", + "react-router-dom": "^6.23.1" }, "devDependencies": { "@types/react": "^18.2.66", @@ -21,6 +25,6 @@ "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", - "vite": "^5.2.0" + "vite": "^5.2.13" } } diff --git a/src/App.css b/src/App.css index 0bf65669..978b2172 100644 --- a/src/App.css +++ b/src/App.css @@ -1,28 +1,176 @@ -.App { +@font-face { + font-family: 'Blacklisted'; + src: url('./assets/Blacklisted.ttf') format('truetype'); +} + +@font-face { + font-family: 'Lato-regular'; + src: url('./assets/Lato/Lato-Regular.ttf') format('truetype'); +} + +#root { + max-width: 1900px; + margin: 0 auto; text-align: center; + background-color: #f5f5f5; +} + +main { + max-width: 1700px; + display: grid; + justify-content: end; + margin-left: 70px; + font-family: 'Lato-regular'; +} + +.header { + border: 2px solid indigo; + width: 100%; + background-color: indigo; + border-bottom-right-radius: 30px; } -.App-header { - background-color: #282c34; + +.footer { display: flex; flex-direction: row; - align-items: center; justify-content: space-evenly; - color: white; + align-items: center; padding: 20px; + background-color: indigo; + color: white; + font-family: 'Montserrat', sans-serif; + border-top-right-radius: 30px; + border-top-left-radius: 30px; } -@media (max-width: 600px) { - .movie-card { - width: 100%; - } +.footer-about { + width: 33%; +} + +.footer-about h3 { + text-align: center; +} + +.footer-about p { + margin-bottom: 0; +} + +.footer-about p span { + display: block; +} + +.footer-contacts { + width: 33%; +} + +.footer-contacts h3 { + text-align: center; +} + +.footer-contacts p { + margin-bottom: 0; + font-size: 18px; +} + +.footer-contacts p a{ + color: #B3E5FC; +} + +.fa-solid { + margin-right: 10px; + font-size: 20px; + color: grey; +} +.footer-copyright { + width: 33%; + text-align: center; +} + +.title { + color: white; + margin-top: 0px; + font-family: 'Blacklisted' +} + +form{ + display: flex; + justify-content: flex-start; + margin-left: 25px; +} + +#search-bar { + padding: 10px; + width: 500px; + margin-right: 3px; + +} + +#search-button { + background-color: #B19CD9; + padding: 10px; + border: 2px solid darkmagenta; + border-radius: 5px; +} + +#search-button:hover, +#nowPlayingButton:hover, +#searchTabButton:hover { + color: white; + background-color: darkmagenta; + border: 2px solid #B19CD9; + border-radius: 5px; +} + +#nowPlayingButton { + background-color: #B19CD9; + padding: 10px; + border: 2px solid darkmagenta; + border-radius: 5px; + margin-right: 10px; +} + +#searchTabButton { + background-color: #B19CD9; + padding: 10px; + border: 2px solid darkmagenta; + border-radius: 5px; +} + + +.searchForm { + display: none; +} - .search-bar { - flex-direction: column; - gap: 10px; +#dropdown-menu { + margin-left: 10px; + padding: 10px; + background-color: #B19CD9; + border: 2px solid darkmagenta; + border-radius: 5px; + text-align: center; +} + +.side-bar-logo { + font-size: 30px; + display: grid; + margin-left: 30px; + margin-top: 20px; + color: #f5f5f5; +} + +.side-bar-logo:hover { + transform: scale(1.2); +} + +@media all and (max-width: 630px) { + #search-bar { + width: 300px; } +} - .search-bar form { - flex-direction: column; +@media all and (max-width: 400px) { + #search-bar { + width: 100px; } } diff --git a/src/App.jsx b/src/App.jsx index 48215b3f..ecef07d8 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,217 @@ -import { useState } from 'react' -import './App.css' +import React from 'react'; +import MovieList from './MovieList'; +import Search from './Search'; +import { useEffect, useState } from 'react'; +import SideBar from './SideBar'; +import { FaBarsStaggered } from "react-icons/fa6"; +import './App.css'; +import "@fortawesome/fontawesome-free/css/all.min.css"; -const App = () => { -
- -
+function App() { + const [movies, setMovies] = useState([]); + const [page, setPage] = useState(1); + const [searchValue, setSearchValue] = useState(''); + const [selectedGenre, setSelectedGenre] = useState(''); + const [movieID, setMovieID] = useState(''); + const [showSideBar, setShowSideBar] = useState(false); + const [likedList, setLikedList] = useState([]); + const [watchedList, setWatchedList] = useState([]); + const apiKey = import.meta.env.VITE_API_KEY; + + useEffect(() => { + getMovies(); + }, [page]) + + useEffect(() => { + searchMovies() + }, [searchValue]) + + const loadMore = () => { + setPage(page => page + 1); +}; + + const movieClick = (movieId) => { + setMovieID(movieId); + } + + const getMovies = async () => { + const url = `https://api.themoviedb.org/3/movie/now_playing?language=en-US&page=${page}&api_key=0d7613c1b95dbc61f3dd491c8f802475`; + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}` + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + if (page === 1){ + setMovies(jsonResponse.results) + } else { + setMovies(prevMovies => [...prevMovies, ...jsonResponse.results]) + } + + } + + const searchMovies = async () => { + const result = searchValue.replace(/ +/g, '+'); + const url = `https://api.themoviedb.org/3/search/movie?query=${result}&api_key=0d7613c1b95dbc61f3dd491c8f802475`; + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}` + } + }; + const response = await fetch(url, options); + const jsonResponse = await response.json(); + const results = jsonResponse.results.filter((movie) => { + return movie.title && movie.title.toLowerCase().includes(searchValue.toLowerCase()); + }) + if (results.length === 0){ + return "Try again, No results found :)" + }else { + setMovies(results); + } + + } + + let genreId; + const handleGenreChange = (event) => { + const selectedValue = event.target.value; + if (selectedValue === "comedy") { + genreId = 35; + sortByGenre(genreId); + } else if (selectedValue === "action") { + genreId = 28; + sortByGenre(genreId); + } else if (selectedValue === "rating-desc"){ + sortByRatingDesc(); + } else if (selectedValue === "rating-asc"){ + sortByRatingAsc(); + } + } + + const sortByGenre = async (genreId) => { + const url =`https://api.themoviedb.org/3/discover/movie?include_adult=false&include_video=false&language=en-US&page=${page}&sort_by=popularity.desc&with_genres=${genreId}&api_key=0d7613c1b95dbc61f3dd491c8f802475`; + + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}` + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + setMovies(jsonResponse.results); + } + + const sortByRatingDesc = async () => { + const url = `https://api.themoviedb.org/3/discover/movie?include_adult=false&include_video=false&language=en-US&page=${page}&sort_by=vote_average.desc&vote_average.gte=10&api_key=0d7613c1b95dbc61f3dd491c8f802475`; + + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}` + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + setMovies(jsonResponse.results); + } + + const sortByRatingAsc = async () => { + const url = `https://api.themoviedb.org/3/discover/movie?include_adult=false&include_video=false&language=en-US&page=${page}&sort_by=vote_average.asc&vote_average.gte=5&api_key=0d7613c1b95dbc61f3dd491c8f802475`; + + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}` + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + setMovies(jsonResponse.results); + } + + const handleClickSideBar = () => { + setShowSideBar(!showSideBar); + } + + return ( + <> +
+
+ +
+

🎥 Flix Max 🍿

+ + + + + + + +
+ +
+ +
+ + + ) } -export default App +export default App; diff --git a/src/Modal.css b/src/Modal.css new file mode 100644 index 00000000..0565d604 --- /dev/null +++ b/src/Modal.css @@ -0,0 +1,141 @@ +@font-face { + font-family: 'Lato-regular'; + src: url('./assets/Lato/Lato-Regular.ttf') format('truetype'); + } + +.movie-modal{ + display: flex; + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: hidden; + background-color: rgba(225, 225, 225, 0.5); + justify-content: center; + align-items: center; + animation: fadeIn 0.3s ease-out; +} + +.modal-content { + font-family: 'Lato-regular'; + display: flex; + position: relative; + margin: 10% auto; + padding: 20px; + width: 50%; + border: 3px solid indigo; + border-radius: 10px; + justify-content: center; + box-shadow: 0 4px 6px rgba(225, 225, 225, 0.5); + animation: zoomIn 0.3s ease-out; + color: black; +} + +.modal-info { + justify-content: flex-end; + width: 90%; + padding-left: 20px; +} +.modal-text { + background-color: rgba(255, 255, 255, 0.537); + -webkit-backdrop-filter: blur(5px); + backdrop-filter: blur(5px); + padding: 25px; + border-radius: 10px; + margin-bottom: 3px; + margin-left: 8%; +} + +#close-modal { + justify-self: flex-end; + font-size: 35px; + cursor: pointer; + color: white; + position: relative; + top: -25px; + margin-left: 10px; +} + +#modal-title { + font-size: 25px; + font-weight: bold; + margin-top: 10px; + justify-self: center; + font-family: 'Blacklisted'; +} + +#modal-poster{ + width: 100%; + height: 100%; + justify-self: center; + align-self: center; + border: 2px; + box-shadow: 0 0 10px 4px rgba(63, 61, 61, 0.644); +} + +#release-date { + font-size: 18px; + font-family: 'Lato-regular'; +} + +#movie-overview { + font-size: 18px; + font-family: 'Lato-regular'; +} + +#runtime { + font-size: 18px; + font-family: 'Lato-regular'; +} + +#movie-genre { + font-size: 18px; + font-family: 'Lato-regular'; +} + + +@keyframes fadeIn { + from { + background-color: transparent; + } + to { + background-color: rgba(225, 225, 225, 0.5); + } +} + +@keyframes zoomIn { + from { + transform: scale(0); + opacity: 0; + } + to { + transform: scale(1); + opacity: 1; + } +} + +.movie-trailer { + margin-left: 10px; + position: relative; + width: 100%; + padding-bottom: 56.25%; + height: 0; +} +.movie-trailer iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.background-image { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: -1; + } diff --git a/src/Modal.jsx b/src/Modal.jsx new file mode 100644 index 00000000..19734bf0 --- /dev/null +++ b/src/Modal.jsx @@ -0,0 +1,47 @@ +import './Modal.css'; + +const Modal = (props) => { + const posterImage = `https://image.tmdb.org/t/p/w500${props.image}`; + const genreNames = props.genres.map(genre => genre.name); + const genreNamesString = genreNames.join(', '); + let runtime; + if(props.runtime === 0) { + runtime = "Not Available" + }else { + runtime = `${props.runtime} minutes` + } + const backdropImage = `https://media.themoviedb.org/t/p/w1920_and_h800_multi_faces/${props.backdrop}` + return ( +
+
+
+
+ {props.movieTitle}/ +
+
+
+ +

Release Date: {props.releaseDate}

+

Runtime: {runtime}

+

{props.movieOverview}

+

Genres: {genreNamesString}

+
+
+ +
+
+ × +
+
+ ) +} + +export default Modal; diff --git a/src/MovieCard.css b/src/MovieCard.css new file mode 100644 index 00000000..49497567 --- /dev/null +++ b/src/MovieCard.css @@ -0,0 +1,74 @@ +.imageContainer { + border: 2px solid indigo; + border-radius: 10px; + display: inline-flex; + flex-direction: column; + width: 250px; + height: auto; + justify-content: center; + margin: 30px 10px 10px 30px; + background-color: #f5f5f5; + transition: transform 0.3s ease-in-out; + will-change: transform; +} + +.imageContainer:hover { + transform: scale(0.9) rotate(3deg); + cursor: pointer; +} + +#movie-poster { + width: 100%; + height: 90%; + align-self: center; +} + +#movie-title { + font-size: 18px; + font-weight: bold; + margin-bottom: 10px; + flex-shrink: 1; + color: indigo; +} + +#movie-rating { + font-size: 16px; + margin-top: 5px; + font-weight: bold; +} + +.bad { + color: red; +} + +.okay { + color: orange; +} + +.good { + color: lightgreen; +} + +#like-count { + font-weight: bold; + cursor: pointer; + color: indigo; + margin-left: 12px; +} + +#check-box { + font-weight: bold; + color: indigo; +} + +@media all and (max-width: 630px) { + .imageContainer { + width: 150px; + } +} + +@media all and (max-width: 800px) { + .imageContainer { + width: 190px; + } +} diff --git a/src/MovieCard.jsx b/src/MovieCard.jsx new file mode 100644 index 00000000..1525f94f --- /dev/null +++ b/src/MovieCard.jsx @@ -0,0 +1,128 @@ +import { useState, useEffect } from 'react'; +import Modal from './Modal'; +import './MovieCard.css'; + +const MovieCard = (props) => { + const [isClicked, setIsClicked] = useState(false); + const [genres, setGenres] = useState([]); + const [runtime, setRuntime] = useState(''); + const [backdrop, setBackdrop] = useState(''); + const [likeCount, setLikeCount] = useState(0); + const [isChecked, setIsChecked] = useState(false); + const [isLiked, setIsLiked] = useState(false); + const [videoLink, setVideoLink] = useState(''); + const apiKey = import.meta.env.VITE_API_KEY; + + useEffect(() => { + fetchMoreInfo(props.id); + fetchVideo(); + }, [isClicked]) + + const toggleModal = () => { + setIsClicked(!isClicked); + } + + const toggleLike = () => { + setIsLiked(!isLiked); + } + + const toggleWatched = () => { + setIsChecked(!isChecked); + } + + const increaseLikes = () => { + if (likeCount === 0) { + const heart = document.getElementById(props.id).querySelector('#like-count'); + setLikeCount(likeCount + 1); + heart.innerText = `❤️`; + } else if (likeCount >= 1) { + const heart = document.getElementById(props.id).querySelector('#like-count'); + setLikeCount(likeCount - 1); + heart.innerText = `♡`; + } + } + + + const fetchMoreInfo = async () => { + const url = `https://api.themoviedb.org/3/movie/${props.id}?language=en-US&api_key=0d7613c1b95dbc61f3dd491c8f802475` + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}`, + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + setBackdrop(jsonResponse.backdrop_path); + setGenres(jsonResponse.genres); + setRuntime(jsonResponse.runtime); + } + + const fetchVideo = async () => { + const url = `https://api.themoviedb.org/3/movie/${props.id}/videos?language=en-US&api_key=0d7613c1b95dbc61f3dd491c8f802475` + const options = { + method: 'GET', + headers: { + accept: 'application/json', + Authorization: `Bearer ${apiKey}`, + } + }; + + const response = await fetch(url, options); + const jsonResponse = await response.json(); + const results = jsonResponse.results; + let videoKey; + results.forEach(item => { + videoKey = item.key; + }); + setVideoLink(`https://www.youtube.com/embed/${videoKey}`); + } + + function handleLike() { + increaseLikes(); + toggleLike(); + if (isLiked) { + if (props.likedList.some(movie => movie.id === props.id)) { + const updatedLikedList = props.likedList.filter(movie => movie.id !== props.id); + props.setLikedList(updatedLikedList); + } + } else { + if (!props.likedList.some(movie => movie.id === props.id)) { + props.setLikedList(isLikedList => [...isLikedList, { id: props.id, image: props.image, title: props.title }]); + } + } + } + + function handleWatched() { + toggleWatched(); + if (isChecked) { + if (props.watchedList.some(movie => movie.id === props.id)) { + const updatedWatchedList = props.watchedList.filter(movie => movie.id !== props.id); + props.setWatchedList(updatedWatchedList); + } + }else { + if (!props.watchedList.some(movie => movie.id === props.id)) { + props.setWatchedList(isWatchedList => [...isWatchedList, {id: props.id, image: props.image, title: props.title}]) + } + } + } + + const className = Number(props.rating) < 5 ? 'bad' : Number(props.rating) < 7.5 ? 'okay' : 'good' + return ( +
+
+ {props.title}/ +

{props.title}

+ +

{props.rating}

+
+ +
+ ) +} + +export default MovieCard diff --git a/src/MovieList.css b/src/MovieList.css new file mode 100644 index 00000000..de73d633 --- /dev/null +++ b/src/MovieList.css @@ -0,0 +1,20 @@ +#load-more { + background-color: darkmagenta; + color: white; + margin-top: 5px; + padding: 12px; + height: 50px; + margin-bottom: 5px; +} + +.movie-list { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; +} + + +.load-class { + justify-content: center; +} diff --git a/src/MovieList.jsx b/src/MovieList.jsx new file mode 100644 index 00000000..0d7c4a23 --- /dev/null +++ b/src/MovieList.jsx @@ -0,0 +1,34 @@ +import './MovieList.css'; +import MovieCard from './MovieCard'; + + + +const MovieList = (props) => { + const uniqueMovies = Array.from(new Map(props.data.map(movie => [movie.id, movie])).values()); + + return ( + <> +
+ {uniqueMovies.map(movie => { + const posterImage = `https://image.tmdb.org/t/p/w500${movie.poster_path}`; + return ( +
props.handleMovieClick(movie.id)}> + +
+ ); + })} +
+
+
+ +
+ + ); +}; + +export default MovieList diff --git a/src/Search.jsx b/src/Search.jsx new file mode 100644 index 00000000..e3709243 --- /dev/null +++ b/src/Search.jsx @@ -0,0 +1,16 @@ +import { useEffect, useState } from 'react'; +import './App.css'; + + +const Search = (props) => { + return ( +
+
+ props.setSearchValue(event.target.value)} placeholder="Search" id="search-bar"> + +
+
+ ) +} + +export default Search diff --git a/src/SideBar.css b/src/SideBar.css new file mode 100644 index 00000000..15aa60d7 --- /dev/null +++ b/src/SideBar.css @@ -0,0 +1,45 @@ +@font-face { + font-family: 'Lato-regular'; + src: url('./assets/Lato/Lato-Regular.ttf') format('truetype'); + } + + @font-face { + font-family: 'Lato-bold'; + src: url('./assets/Lato/Lato-Bold.ttf') format('truetype'); + } + +.side-bar { + width: 200px; + background-color: darkmagenta; + position: absolute; + min-height: 100vh; + padding: 0 30px; + left: -100%; + transition: all 0.5s; + color: white; + display: block; + z-index: 100; +} + +.side-bar.active { + left: 0; +} + +ul { + padding: 0; + font-family: 'Lato-bold'; +} + +li { + list-style-type: none; + font-size: 16px; + font-weight: bold; +} + +.side-bar-content{ + font-size: 18px; +} + +.side-bar-title { + font-size: 20px; +} diff --git a/src/SideBar.jsx b/src/SideBar.jsx new file mode 100644 index 00000000..1abcbdbe --- /dev/null +++ b/src/SideBar.jsx @@ -0,0 +1,46 @@ +import React from 'react'; +import { useState } from 'react'; +import SideBarCard from './SideBarCard'; +import './SideBar.css'; + +const SideBar = (props) => { + const likedMovies = props.likedList; + const watchedMovies = props.watchedList; + return ( +
+
+

SideBar

+
+
+
    +
    +
  • Liked Movies
  • + {likedMovies.map(movie => ( + + ))} +
    +
    +
  • Watched Movies
  • + {watchedMovies.map(movie => ( + + ))} +
    +
+
+
+ ) +} + +export default SideBar; diff --git a/src/SideBarCard.css b/src/SideBarCard.css new file mode 100644 index 00000000..daa1cfb6 --- /dev/null +++ b/src/SideBarCard.css @@ -0,0 +1,26 @@ +.side-bar-card { + border: 2px solid indigo; + border-radius: 10px; + display: flex; + flex-direction: column; + width: 70px; + height: auto; + justify-content: center; +} + + +.sidebar-poster { + width: 70px; + height: 80%; + align-self: center; + margin-bottom: 0px; +} + +.sidebar-movie-title { + font-size: 13px; + font-weight: bold; + margin-bottom: 5px; + flex-shrink: 1; + color: white; + margin-top: 0px; +} diff --git a/src/SideBarCard.jsx b/src/SideBarCard.jsx new file mode 100644 index 00000000..1115cad0 --- /dev/null +++ b/src/SideBarCard.jsx @@ -0,0 +1,13 @@ +import React from 'react'; +import './SideBarCard.css'; + +const SideBarCard = (props) => { + return ( +
+ {props.title}/ +

{props.title}

+
+ ) +} + +export default SideBarCard; diff --git a/src/assets/Blacklisted.ttf b/src/assets/Blacklisted.ttf new file mode 100644 index 00000000..81d9f96e Binary files /dev/null and b/src/assets/Blacklisted.ttf differ diff --git a/src/assets/Lato/Lato-Black.ttf b/src/assets/Lato/Lato-Black.ttf new file mode 100644 index 00000000..4340502d Binary files /dev/null and b/src/assets/Lato/Lato-Black.ttf differ diff --git a/src/assets/Lato/Lato-BlackItalic.ttf b/src/assets/Lato/Lato-BlackItalic.ttf new file mode 100644 index 00000000..4df1555e Binary files /dev/null and b/src/assets/Lato/Lato-BlackItalic.ttf differ diff --git a/src/assets/Lato/Lato-Bold.ttf b/src/assets/Lato/Lato-Bold.ttf new file mode 100644 index 00000000..016068b4 Binary files /dev/null and b/src/assets/Lato/Lato-Bold.ttf differ diff --git a/src/assets/Lato/Lato-BoldItalic.ttf b/src/assets/Lato/Lato-BoldItalic.ttf new file mode 100644 index 00000000..a05d5032 Binary files /dev/null and b/src/assets/Lato/Lato-BoldItalic.ttf differ diff --git a/src/assets/Lato/Lato-Italic.ttf b/src/assets/Lato/Lato-Italic.ttf new file mode 100644 index 00000000..0d0f69ea Binary files /dev/null and b/src/assets/Lato/Lato-Italic.ttf differ diff --git a/src/assets/Lato/Lato-Light.ttf b/src/assets/Lato/Lato-Light.ttf new file mode 100644 index 00000000..dfa72ce8 Binary files /dev/null and b/src/assets/Lato/Lato-Light.ttf differ diff --git a/src/assets/Lato/Lato-LightItalic.ttf b/src/assets/Lato/Lato-LightItalic.ttf new file mode 100644 index 00000000..12f2b6c7 Binary files /dev/null and b/src/assets/Lato/Lato-LightItalic.ttf differ diff --git a/src/assets/Lato/Lato-Regular.ttf b/src/assets/Lato/Lato-Regular.ttf new file mode 100644 index 00000000..bb2e8875 Binary files /dev/null and b/src/assets/Lato/Lato-Regular.ttf differ diff --git a/src/assets/Lato/Lato-Thin.ttf b/src/assets/Lato/Lato-Thin.ttf new file mode 100644 index 00000000..ba58da1a Binary files /dev/null and b/src/assets/Lato/Lato-Thin.ttf differ diff --git a/src/assets/Lato/Lato-ThinItalic.ttf b/src/assets/Lato/Lato-ThinItalic.ttf new file mode 100644 index 00000000..4d82766d Binary files /dev/null and b/src/assets/Lato/Lato-ThinItalic.ttf differ diff --git a/src/assets/Lato/OFL.txt b/src/assets/Lato/OFL.txt new file mode 100644 index 00000000..1d7bf3b7 --- /dev/null +++ b/src/assets/Lato/OFL.txt @@ -0,0 +1,93 @@ +Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato" + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE.