-
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.
16_filter_and_search_01 item displayed
16_filter_and_search_01 item displayed on html page from javascript code, elements created and images added from javascript code
- Loading branch information
1 parent
d252a39
commit d021474
Showing
11 changed files
with
180 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,82 @@ | ||
let products = { | ||
data: [ | ||
{ | ||
productName: "Regular White T-Shirt", | ||
category: "Topwear", | ||
price: "30", | ||
image: "white-tshirt.jpg", | ||
}, | ||
{ | ||
productName: "Beige Short Skirt", | ||
category: "Bottomwear", | ||
price: "49", | ||
image: "short-skirt.jpg", | ||
}, | ||
{ | ||
productName: "Sporty SmartWatch", | ||
category: "Watch", | ||
price: "99", | ||
image: "sporty-smartwatch.jpg", | ||
}, | ||
{ | ||
productName: "Basic Knitted Top", | ||
category: "Topwear", | ||
price: "29", | ||
image: "knitted-top.jpg", | ||
}, | ||
{ | ||
productName: "Black Leather Jacket", | ||
category: "Jacket", | ||
price: "129", | ||
image: "black-leather-jacket.jpg", | ||
}, | ||
{ | ||
productName: "Stylish Pink Trousers", | ||
category: "Bottomwear", | ||
price: "89", | ||
image: "pink-trousers.jpg", | ||
}, | ||
{ | ||
productName: "Brown Men's Jacket", | ||
category: "Jacket", | ||
price: "189", | ||
image: "brown-jacket.jpg", | ||
}, | ||
{ | ||
productName: "Comfy Gray Pants", | ||
category: "Bottomwear", | ||
price: "49", | ||
image: "comfy-gray-pants.jpg", | ||
}, | ||
], | ||
}; | ||
|
||
for (let i of products.data) { | ||
////Creating card | ||
let card = document.createElement("div"); | ||
////Card should have category | ||
card.classList.add("card", i.category); | ||
////image div | ||
let imgContainer = document.createElement("div"); | ||
imgContainer.classList.add("image-container"); | ||
////img tag | ||
let image = document.createElement("img"); | ||
image.setAttribute("src", i.image); | ||
imgContainer.appendChild(image); | ||
card.appendChild(imgContainer); | ||
////container | ||
let container = document.createElement("div"); | ||
container.classList.add("container"); | ||
////product name | ||
let name = document.createElement("h5"); | ||
name.classList.add("product-name"); | ||
name.innerText = i.productName.toUpperCase(); | ||
container.appendChild(name); | ||
//price | ||
let price = document.createElement("h6"); | ||
price.innerText = "$"+ i.price; | ||
container.appendChild(price); | ||
|
||
card.appendChild(container); | ||
document.getElementById("products").appendChild(card); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,81 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
border: none; | ||
outline: none; | ||
font-family: "Poppins", sans-serif; | ||
} | ||
|
||
body { | ||
background-color: #f5f8ff; | ||
} | ||
|
||
.wrapper{ | ||
width: 95%; | ||
margin: 0 auto; | ||
} | ||
|
||
#search-container { | ||
margin: 1em 0; | ||
} | ||
|
||
#search-container input { | ||
background-color: transparent; | ||
width: 40%; | ||
border-bottom: 2px solid #110f29; | ||
padding: 1em 0.3em; | ||
} | ||
|
||
#search-container input:focus { | ||
border-bottom-color: #6759ff; | ||
} | ||
|
||
#search-container button { | ||
padding: 1em 2em; | ||
margin-left: 1em; | ||
background-color: #6759ff; | ||
color: #ffffff; | ||
border-radius: 5px; | ||
margin-top: 0.5em; | ||
} | ||
|
||
.button-value { | ||
border: 2px solid #6759ff; | ||
padding: 1em 2.2em; | ||
border-radius: 3em; | ||
background-color: transparent; | ||
color: #6759ff; | ||
cursor: pointer; | ||
} | ||
|
||
.active { | ||
background-color: #6759ff; | ||
color: #ffffff; | ||
} | ||
|
||
#products { | ||
display: grid; | ||
grid-template-columns: auto auto auto; | ||
grid-column-gap: 1.5em; | ||
padding: 2em 0; | ||
} | ||
|
||
.card { | ||
background-color: #ffffff; | ||
max-width: 18em; | ||
margin-top: 1em; | ||
padding: 1em; | ||
border-radius: 5px; | ||
box-shadow: 1em 2em 2.5em rgba(1, 2, 68, 0.08); | ||
} | ||
|
||
.image-container { | ||
text-align: center; | ||
} | ||
|
||
img { | ||
max-width: 100%; | ||
object-fit: contain; | ||
height: 15em; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.