-
Notifications
You must be signed in to change notification settings - Fork 223
feat: Flixter - Pull Request to base repo #64
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
a212b3b
d5fe3a0
7c520e9
1cfb8fb
0e35622
d07ab11
915b10f
5cd679c
402ac4c
656266e
40afa37
ebffc7e
594f8a5
420d182
53e5c83
b8198a1
b237211
bcc4e0a
8536e31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,14 @@ | ||
| import { useState } from 'react' | ||
| import './App.css' | ||
| import MovieCard from './MovieCard' | ||
| import data from './data/data' | ||
| import MovieList from './MovieList' | ||
|
|
||
| const App = () => { | ||
| // Get the movies from the data | ||
| const movies = data.results; | ||
|
|
||
| return ( | ||
| <div className="App"> | ||
| <header className="App-header"> | ||
| <h1>Flixster</h1> | ||
| inp | ||
| </header> | ||
| <div className="movie-container" style={{ | ||
| display: 'flex', | ||
| flexWrap: 'wrap', | ||
| justifyContent: 'center', | ||
| padding: '20px' | ||
| }}> | ||
| {movies.map(movie => ( | ||
| <MovieCard key={movie.id} movie={movie} /> | ||
| ))} | ||
| </div> | ||
| <MovieList /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Glad to see that you have created a modularized component |
||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| .movie-card { | ||
| width: 200px; | ||
| margin: 1rem; | ||
| border-radius: 8px; | ||
| overflow: hidden; | ||
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | ||
| transition: transform 0.3s ease; | ||
| background-color: #1a1a1a; | ||
| } | ||
|
|
||
| .movie-card:hover { | ||
| transform: scale(1.03); | ||
| } | ||
|
|
||
| .movie-poster { | ||
| width: 100%; | ||
| height: 300px; | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| .movie-info { | ||
| padding: 1rem; | ||
| } | ||
|
|
||
| .movie-title { | ||
| margin: 0 0 0.5rem 0; | ||
| font-size: 1rem; | ||
| color: white; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .movie-vote { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .vote-average { | ||
| background-color: #ffd700; | ||
| color: black; | ||
| padding: 0.2rem 0.5rem; | ||
| border-radius: 4px; | ||
| font-weight: bold; | ||
| font-size: 0.9rem; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| .movie-list-container { | ||
| padding: 20px; | ||
| } | ||
|
|
||
| .section-title { | ||
| font-size: 1.8rem; | ||
| margin-bottom: 20px; | ||
| color: #fff; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .movie-list { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| justify-content: center; | ||
| gap: 20px; | ||
| } | ||
|
|
||
| .loading, .error { | ||
| text-align: center; | ||
| padding: 40px; | ||
| font-size: 1.2rem; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .error { | ||
| color: #ff6b6b; | ||
| } | ||
|
|
||
| /* Responsive adjustments */ | ||
| @media (max-width: 768px) { | ||
| .movie-list { | ||
| gap: 15px; | ||
| } | ||
|
|
||
| .section-title { | ||
| font-size: 1.5rem; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { useState, useEffect } from 'react'; | ||
| import MovieCard from './MovieCard'; | ||
| import './MovieList.css'; | ||
|
|
||
| const MovieList = () => { | ||
| const [movies, setMovies] = useState([]); | ||
| const [loading, setLoading] = useState(true); | ||
| const [error, setError] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const fetchMovies = async () => { | ||
| const apiKey = import.meta.env.VITE_API_KEY; | ||
| const url = `https://api.themoviedb.org/3/movie/now_playing?api_key=${apiKey}&language=en-US&page=1`; | ||
|
|
||
| try { | ||
| const response = await fetch(url); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`HTTP error! Status: ${response.status}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| setMovies(data.results); | ||
| setLoading(false); | ||
| } catch (error) { | ||
| console.error("Error fetching movies:", error); | ||
| setError("Failed to fetch movies. Please try again later."); | ||
| setLoading(false); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to implement error page and show user friendly error message on the browser for exceptions |
||
| } | ||
| }; | ||
|
|
||
| fetchMovies(); | ||
| }, []); | ||
|
|
||
| if (loading) { | ||
| return <div className="loading">Loading movies...</div>; | ||
| } | ||
|
|
||
| if (error) { | ||
| return <div className="error">{error}</div>; | ||
| } | ||
|
|
||
| return ( | ||
| <main className="movie-list-container"> | ||
| <h2 className="section-title">Now Playing</h2> | ||
| <section className="movie-list"> | ||
| {movies.map(movie => ( | ||
| <MovieCard key={movie.id} movie={movie} /> | ||
| ))} | ||
| </section> | ||
| </main> | ||
| ); | ||
| }; | ||
|
|
||
| export default MovieList; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is typo ?