From b1ec8682ff530e8f5304d5dc4515a3e38a9d1c06 Mon Sep 17 00:00:00 2001 From: Abdilahi mohamed Date: Thu, 8 Dec 2022 12:50:45 +0300 Subject: [PATCH] finished tv-api project --- index.html | 12 +++++++----- script.js | 41 ++++++++++++++++++++++++++++++++++++++++- style.css | 13 ++++++++++--- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 4ab20ee..84e00b1 100644 --- a/index.html +++ b/index.html @@ -27,15 +27,14 @@
- -
+
Search for your favorite shows
- - + +
- +
@@ -50,6 +49,7 @@

Breaking Bad

movie @@ -59,5 +59,7 @@

Breaking Bad

+ + diff --git a/script.js b/script.js index 12d5a38..a5bcb3c 100644 --- a/script.js +++ b/script.js @@ -1 +1,40 @@ -//code + + +// https://api.tvmaze.com/search/shows?q=girls + +document.querySelector('#search').addEventListener('click',() => { + let Film = document.querySelector('.search-box').value; + let newFilm = Film + fetch(`https://api.tvmaze.com/search/shows?q=${newFilm}`) + .then((movie) =>{ + return movie.json(); + }) + .then((data) =>{ + console.log(data) + + for(let i=0; i< data.length; i++){ + let movieCard = document.createElement('div'); + movieCard.classList.add('movie-card'); + document.querySelector('.movies-section').appendChild(movieCard); + + let movieContainer= document.createElement('div'); + movieContainer.classList.add('movie-image'); + movieCard.appendChild(movieContainer); + + let movieImg = document.createElement('img'); + movieImg.src = data[i].show.image.medium; + movieContainer.appendChild(movieImg); + + let title = document.createElement('h3'); + title.classList.add('movie-heading') + title.innerHTML = data[i].show.name + movieCard.appendChild(title); + } + }) + }) + + + + + // console.log(data[0].show.image.medium); + // data[i].show.name; \ No newline at end of file diff --git a/style.css b/style.css index 7859aa5..1d6d108 100644 --- a/style.css +++ b/style.css @@ -49,6 +49,7 @@ } #search{ + cursor: pointer; background: red; border:none; padding:7px 12px; @@ -64,11 +65,15 @@ .movies-section { display: flex; - margin: 15px 50px; + justify-content: center; + flex-wrap: wrap; + gap: 5px; + /* margin: 15px 30px; */ } .movie-card { - margin: 0px 10px; + margin: 0px 4px; + border: 4px solid red; } .movie-image { @@ -81,5 +86,7 @@ .movie-heading { font-weight: bold; - color: red; + color: rgb(90, 5, 5); } + +