Skip to content

Commit

Permalink
Merge pull request #141 from Yashgabani845/yash-work2
Browse files Browse the repository at this point in the history
Movie Database API added
  • Loading branch information
dishamodi0910 authored May 26, 2024
2 parents 75cf1bd + 192b09b commit 179c5f2
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Existing_API_Collection/Movies_API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;500&display=swap" rel="stylesheet">

<link rel="stylesheet" href="./style.css">
<title>Movie Api</title>
</head>
<body>
<h1>Movie Search API</h1>
<form action="">
<input type="text" class="search-input" placeholder="search for movie...">
<button>Search</button>
</form>
<div class="image-container">

</div>



<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script> -->
<script src="./script.js"></script>
<!-- <script src="./notes.js"></script> -->
</body>

</html>
34 changes: 34 additions & 0 deletions Existing_API_Collection/Movies_API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const form = document.querySelector('form')
const gallery = document.querySelector('.image-container');


form.addEventListener('submit',(e)=>{
e.preventDefault();
let query=form.querySelector('input').value;
form.querySelector('input').value='';

if(query==''){
query="nothing";
}
tvMazeApi(query);
})

async function tvMazeApi(query){
const res=await fetch(`https://api.tvmaze.com/search/shows?q=${query}`);
const shows=await res.json();
console.log(shows);
makeImages(shows);
}

function makeImages(shows) {
for(let show of shows)
{
if(show.show.image)
{
console.log(show.show.image.medium);
const img = document.createElement('img');
img.src=show.show.image.medium;
gallery.append(img);
}
}
}
92 changes: 92 additions & 0 deletions Existing_API_Collection/Movies_API/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
min-height: 100vh;
background-color: #000;
}

h1 {
text-align: center;
color: #fff;
margin-top: 1rem;
}

form {
text-align: center;
margin-top: 1rem;
display: flex;
justify-content: center;
gap: 0.5rem;
margin-bottom: 30px;
}

.search-input {
font-size: 1.2rem;
padding: 0.5em;
border-radius: 0.25rem;
border: none;
outline: none;
background-color: #eaeaea;
transition: box-shadow 0.3s ease;
}

.search-input:focus {
box-shadow: 0 0 4px 2px rgba(238, 170, 67, 0.8);
}

button {
font-size: 1rem;
padding: 0.5em 1em;
background-color: #078686;
color: #fff;
border: none;
font-weight: bold;
border-radius: 0.25em;
box-shadow: 1px 1px 2px 2px #636161;
transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

button:hover {
cursor: pointer;
background-color: rgba(6, 118, 118, 0.85);
}

button:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 2px 1px #636161;
}

img {
display: block;
width: 100%;
box-shadow: 0 0 5px #5d5d5d;
transition: transform 0.3s linear;
cursor: pointer;
overflow: hidden;
}

img:hover {
transform: scale(1.05);
}

.image-container {
display: grid;
place-content: center;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 20px;
width: 90%;
margin: 10px auto;
}

@media (max-width: 580px) {
img {
height: 350px;
}
.image-container {
grid-template-columns: repeat(auto-fit, minmax(250px, 300px));
}
}

0 comments on commit 179c5f2

Please sign in to comment.