diff --git a/src/App.jsx b/src/App.jsx index eeec100..e831b61 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,15 +1,19 @@ import { Routes, Route } from "react-router-dom" -import "./App.css" import Home from "pages/Home" import Movie from "pages/Movie" import Actor from "pages/Actor" +import Ratings from "pages/Ratings" +import styles from "styles/App.module.css" +import TopBar from "components/TopBar" const App = () => ( -
+
+ } /> } /> } /> + } /> 404 - Not Found} />
diff --git a/src/components/Card.jsx b/src/components/Card.jsx index f8c9549..3a60963 100644 --- a/src/components/Card.jsx +++ b/src/components/Card.jsx @@ -1,7 +1,8 @@ import { Link } from "react-router-dom" import styles from "styles/Card.module.css" +import Rate from "./Rate" -const Card = ({ movie }) => ( +const Card = ({ movie, setRating }) => (
(

{movie.title} - {movie.year}

-

- {movie.averageVote}{" "} - - - -

+ {movie.rating ? ( + + ) : ( +

+ Average rating: {movie.averageVote}{" "} + + + +

+ )}

{movie.overview}

diff --git a/src/components/CardList.jsx b/src/components/CardList.jsx deleted file mode 100644 index 25c7847..0000000 --- a/src/components/CardList.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import Card from "components/Card"; -import styles from "styles/CardList.module.css"; - -const CardList = ({ movies }) => ( -
- {movies?.map((movie) => ( - - ))} -
-); - -export default CardList; diff --git a/src/components/Rate.jsx b/src/components/Rate.jsx index a10fc2c..6eed1bf 100644 --- a/src/components/Rate.jsx +++ b/src/components/Rate.jsx @@ -3,7 +3,6 @@ import styles from "styles/Rate.module.css" const Rate = ({ rating, setRating }) => { const [hover, setHover] = useState() - return (
{[...Array(5)].map((_, index) => { @@ -15,7 +14,10 @@ const Rate = ({ rating, setRating }) => { className={`${styles.Star} ${ index <= (hover || rating) ? styles.On : styles.Off }`} - onClick={() => setRating(index)} + onClick={(event) => { + event.preventDefault() + setRating(index) + }} onMouseEnter={() => setHover(index)} onMouseLeave={() => setHover()} > diff --git a/src/components/TopBar.jsx b/src/components/TopBar.jsx index 40a14ee..b1a27a8 100644 --- a/src/components/TopBar.jsx +++ b/src/components/TopBar.jsx @@ -1,16 +1,14 @@ +import { Link } from "react-router-dom" import styles from "styles/TopBar.module.css" -const TopBar = ({ search, setSearch }) => ( +const TopBar = () => (
-

React Movie Finder

- setSearch(target.value)} - /> + +

React Movie Finder

+ + +

Your ratings

+
) diff --git a/src/index.css b/src/index.css index b2f5e28..49cf7e7 100644 --- a/src/index.css +++ b/src/index.css @@ -28,7 +28,7 @@ button { } hr { - width: 97%; + width: 100%; color: white; } diff --git a/src/pages/Actor.jsx b/src/pages/Actor.jsx index 993ebe7..411c814 100644 --- a/src/pages/Actor.jsx +++ b/src/pages/Actor.jsx @@ -63,7 +63,8 @@ const Actor = () => { return (
-

{actor?.name}

+
+

{actor?.name}

Biography

diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 2551ab4..26f91b2 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -47,7 +47,14 @@ const Home = () => { return (
- + setSearch(target.value)} + />
{movies?.map((movie) => ( diff --git a/src/pages/Movie.jsx b/src/pages/Movie.jsx index 230868d..2f76673 100644 --- a/src/pages/Movie.jsx +++ b/src/pages/Movie.jsx @@ -93,6 +93,10 @@ const Movie = () => {

Your Rating

+
+ + Go to ratings +

Actors

diff --git a/src/pages/Ratings.jsx b/src/pages/Ratings.jsx new file mode 100644 index 0000000..e85dabb --- /dev/null +++ b/src/pages/Ratings.jsx @@ -0,0 +1,29 @@ +import Card from "components/Card" +import useLocalStorage from "hooks/useLocalStorage" +import styles from "styles/Ratings.module.css" + +const Ratings = () => { + const [ratings, setRatings] = useLocalStorage("ratings", []) + const setRating = (rating, movie) => + setRatings((currentRatings) => [ + ...currentRatings.filter(({ id }) => id != movie.id), + { ...movie, rating }, + ]) + + return ( +
+
+
+ {ratings?.map((movie) => ( + setRating(rating, movie)} + /> + ))} +
+
+ ) +} + +export default Ratings diff --git a/src/styles/Actor.module.css b/src/styles/Actor.module.css index 21f2480..19a77e9 100644 --- a/src/styles/Actor.module.css +++ b/src/styles/Actor.module.css @@ -3,6 +3,10 @@ flex-direction: column; padding: 15px; color: white; + padding-top: 80px; +} +.Name { + margin-top: 10px; } .Images { diff --git a/src/App.css b/src/styles/App.module.css similarity index 100% rename from src/App.css rename to src/styles/App.module.css diff --git a/src/styles/Home.module.css b/src/styles/Home.module.css index e70b607..da286f9 100644 --- a/src/styles/Home.module.css +++ b/src/styles/Home.module.css @@ -3,6 +3,7 @@ align-items: center; flex-direction: column; gap: 1.5em; + padding-top: 30px; } .CardList { @@ -14,3 +15,14 @@ gap: 20px; text-align: center; } + +.Search { + padding: 0.5em; + border: 2px solid white; + color: white; + font: inherit; + width: 20em; + height: 3em; + border-radius: 10px; + background-color: var(--secondary); +} diff --git a/src/styles/Movie.module.css b/src/styles/Movie.module.css index f48459f..c83f0df 100644 --- a/src/styles/Movie.module.css +++ b/src/styles/Movie.module.css @@ -66,3 +66,7 @@ .Rate { color: white; } + +.RatingsLink { + color: white; +} diff --git a/src/styles/Ratings.module.css b/src/styles/Ratings.module.css new file mode 100644 index 0000000..39e2851 --- /dev/null +++ b/src/styles/Ratings.module.css @@ -0,0 +1,19 @@ +.Container { + display: flex; + align-items: center; + flex-direction: column; + gap: 1.5em; + color: white; + padding: 10px; + padding-top: 90px; +} + +.CardList { + display: grid; + justify-items: center; + width: 100%; + padding: 20px; + grid-template-columns: repeat(auto-fit, minmax(250px, 300px)); + gap: 20px; + text-align: center; +} diff --git a/src/styles/TopBar.module.css b/src/styles/TopBar.module.css index 57dd76d..ab768b1 100644 --- a/src/styles/TopBar.module.css +++ b/src/styles/TopBar.module.css @@ -1,21 +1,13 @@ .Container { display: flex; width: 100%; - flex-direction: column; - align-items: center; -} - -.Search { - padding: 0.5em; - border: 2px solid white; - color: white; - font: inherit; - width: 20em; - height: 3em; - border-radius: 10px; - background-color: var(--secondary); -} - -.Title { + justify-content: space-between; + padding: 10px 20px; + background-color: transparent; + position: absolute; + color: white; +} + +.Container h1 { color: white; }