forked from Open-Source-Chandigarh/SearchMovies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 28ed904
Showing
11 changed files
with
379 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# React + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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>Movies</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "01-search-movies", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.6.8", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.66", | ||
"@types/react-dom": "^18.2.22", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-react": "^7.34.1", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.6", | ||
"vite": "^5.2.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
@import url("https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700"); | ||
@import url("https://fonts.googleapis.com/css?family=Raleway:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i"); | ||
|
||
* { | ||
margin: 0; | ||
border: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
:root { | ||
--font-roboto: "Roboto Slab", serif; | ||
--font-raleway: "Raleway", sans-serif; | ||
} | ||
|
||
body { | ||
font-family: var(--font-roboto); | ||
background-color: #212426; | ||
} | ||
|
||
.app { | ||
padding: 4rem; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
} | ||
|
||
h1 { | ||
font-size: 3rem; | ||
letter-spacing: 0.9px; | ||
background: linear-gradient( | ||
90deg, | ||
rgba(249, 211, 180, 1) 0%, | ||
rgba(249, 211, 180, 0) 100% | ||
); | ||
background-clip: text; | ||
-webkit-background-clip: text; | ||
-webkit-text-fill-color: transparent; | ||
width: fit-content; | ||
} | ||
|
||
.search { | ||
width: 71%; | ||
margin: 4rem 0 2rem; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
padding: 1.5rem 1.75rem; | ||
border-radius: 3rem; | ||
background: #1f2123; | ||
-webkit-box-shadow: 5px 5px 7px #1c1d1f, -5px -5px 7px #222527; | ||
box-shadow: 5px 5px 7px #1c1d1f, -5px -5px 7px #222527; | ||
} | ||
|
||
.search input { | ||
flex: 1; | ||
border: none; | ||
font-size: 1.5rem; | ||
font-family: var(--font-raleway); | ||
font-weight: 500; | ||
padding-right: 1rem; | ||
|
||
outline: none; | ||
color: #a1a1a1; | ||
background: #1f2123; | ||
} | ||
|
||
.search img { | ||
width: 35px; | ||
height: 35px; | ||
cursor: pointer; | ||
} | ||
|
||
/* .search button { | ||
padding: 20px 40px; | ||
border-radius: 0.5rem; | ||
margin-left: 15px; | ||
color: #a1a1a1; | ||
font-family: var(--font-raleway); | ||
font-weight: 900; | ||
letter-spacing: 0.75px; | ||
font-size: 1.25rem; | ||
cursor: pointer; | ||
background: #1f2123; | ||
-webkit-box-shadow: 5px 5px 7px #1c1d1f, -5px -5px 7px #222527; | ||
box-shadow: 5px 5px 7px #1c1d1f, -5px -5px 7px #222527; | ||
} */ | ||
|
||
.empty { | ||
width: 100%; | ||
margin-top: 3rem; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.empty h2 { | ||
font-size: 1.25rem; | ||
color: #f9d3b4; | ||
font-family: var(--font-raleway); | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
margin-top: 3rem; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.movie { | ||
width: 310px; | ||
height: 460px; | ||
margin: 1.5rem; | ||
|
||
position: relative; | ||
border-radius: 12px; | ||
overflow: hidden; | ||
border: none; | ||
|
||
transition: all 0.4s cubic-bezier(0.175, 0.885, 0, 1); | ||
box-shadow: 0px 13px 10px -7px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.movie div:nth-of-type(1) { | ||
position: absolute; | ||
padding: 16px; | ||
width: 100%; | ||
opacity: 0; | ||
top: 0; | ||
color: #f9d3b4; | ||
} | ||
|
||
.movie:hover { | ||
box-shadow: 0px 30px 18px -8px rgba(0, 0, 0, 0.1); | ||
transform: scale(1.05, 1.05); | ||
} | ||
|
||
.movie div:nth-of-type(2) { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.movie div:nth-of-type(2) img { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.movie div:nth-of-type(3) { | ||
z-index: 2; | ||
background-color: #343739; | ||
padding: 16px 24px 24px 24px; | ||
|
||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
} | ||
|
||
.movie div:nth-of-type(3) span { | ||
font-family: "Raleway", sans-serif; | ||
text-transform: uppercase; | ||
font-size: 13px; | ||
letter-spacing: 2px; | ||
font-weight: 500; | ||
color: #f0f0f0; | ||
} | ||
|
||
.movie div:nth-of-type(3) h3 { | ||
margin-top: 5px; | ||
font-family: "Roboto Slab", serif; | ||
color: #f9d3b4; | ||
} | ||
|
||
.movie:hover div:nth-of-type(2) { | ||
height: 100%; | ||
opacity: 0.3; | ||
} | ||
|
||
.movie:hover div:nth-of-type(3) { | ||
background-color: transparent; | ||
} | ||
|
||
.movie:hover div:nth-of-type(1) { | ||
opacity: 1; | ||
} | ||
|
||
@media screen and (max-width: 600px) { | ||
.app { | ||
padding: 4rem 2rem; | ||
} | ||
|
||
.search { | ||
padding: 1rem 1.75rem; | ||
width: 100%; | ||
} | ||
|
||
.search input { | ||
font-size: 1rem; | ||
} | ||
|
||
.search img { | ||
width: 20px; | ||
height: 20px; | ||
} | ||
} | ||
|
||
@media screen and (max-width: 400px) { | ||
.app { | ||
padding: 4rem 1rem; | ||
} | ||
|
||
h1 { | ||
font-size: 2rem; | ||
} | ||
|
||
.container { | ||
margin-top: 2rem; | ||
} | ||
|
||
.movie { | ||
width: "100%"; | ||
margin: 1rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useState, useEffect } from 'react' | ||
import SearchIcon from "./assets/search.svg" | ||
import MovieCard from './MovieCard' | ||
import './App.css' | ||
|
||
function App() { | ||
const [search, setSearch] = useState("") | ||
const [movies, setMovies] = useState([]) | ||
|
||
// d3919209 | ||
const API_URL = "https://www.omdbapi.com/?apikey=d3919209"; | ||
const searchMovies = async (title) => { | ||
const response = await fetch(`${API_URL}&s=${title}`); | ||
const data = await response.json(); | ||
setMovies(data.Search); | ||
} | ||
useEffect(()=>{ | ||
searchMovies(search); | ||
}, [search]); | ||
|
||
|
||
return ( | ||
// react fragment - <> </> if more than one elements...then u need to wrap them around the react fragment | ||
<div className="app"> | ||
<h1>All time Popular Movies</h1> | ||
<div className="search"> | ||
<input | ||
type="text" | ||
placeholder='Search Movies' | ||
value={search} | ||
onChange={(e) => {setSearch(e.target.value)}} | ||
/> | ||
<img | ||
src={SearchIcon} | ||
alt="search" | ||
onClick={() => {searchMovies(search)}} | ||
/> | ||
</div> | ||
|
||
{ | ||
movies?.length > 0 | ||
? ( | ||
<div className="container"> | ||
{movies.map((movie) => { | ||
return <MovieCard movie = {movie}/> | ||
})} | ||
</div> | ||
) : ( | ||
<div className="empty"> | ||
<h2>No Movies Found</h2> | ||
</div> | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
|
||
const MovieCard = (props) => { | ||
return ( | ||
<div className='movie'> | ||
<div> | ||
<p>{props.movie.Year}</p> | ||
</div> | ||
<div> | ||
<img src={props.movie.Poster !== 'N/A' ? props.movie.Poster : 'https://via.placeholder.com/400'} alt="" /> | ||
</div> | ||
<div> | ||
<span>{props.movie.Type}</span> | ||
<h3>{props.movie.Title}</h3> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default MovieCard |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App.jsx' | ||
import './index.css' | ||
|
||
ReactDOM.createRoot(document.getElementById('root')).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
}) |