-
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
Showing
8 changed files
with
216 additions
and
212 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
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
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
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
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,66 @@ | ||
function sidebarFunc() { | ||
//! home sidebar start | ||
const btnOpenSidebar = document.querySelector("#btn-menu"); | ||
const sidebar = document.querySelector("#sidebar"); | ||
const btnCloseSidebar = document.querySelector("#close-sidebar"); | ||
btnOpenSidebar.addEventListener("click", function () { | ||
sidebar.style.left = "0"; | ||
}); | ||
|
||
btnCloseSidebar.addEventListener("click", function () { | ||
sidebar.style.left = "-100%"; | ||
}); | ||
|
||
/* click outside start */ | ||
document.addEventListener("click", function (event) { | ||
if ( | ||
!event.composedPath().includes(sidebar) && | ||
!event.composedPath().includes(btnOpenSidebar) | ||
) { | ||
sidebar.style.left = "-100%"; | ||
} | ||
}); | ||
/* click outside end */ | ||
|
||
//! home sidebar end | ||
} | ||
|
||
function searchModalFunc() { | ||
//! search modal start | ||
const btnOpenSearch = document.querySelector(".search-button"); | ||
const btnCloseSearch = document.getElementById("close-search"); | ||
const modalSearch = document.getElementsByClassName("modal-search"); | ||
const modalSearchWrapper = document.getElementsByClassName("modal-wrapper"); | ||
|
||
btnOpenSearch.addEventListener("click", function () { | ||
modalSearch[0].style.visibility = "visible"; | ||
modalSearch[0].style.opacity = "1"; | ||
}); | ||
|
||
btnCloseSearch.addEventListener("click", function () { | ||
modalSearch[0].style.visibility = "hidden"; | ||
modalSearch[0].style.opacity = "0"; | ||
}); | ||
|
||
/* click outside start */ | ||
document.addEventListener("click", function (e) { | ||
if ( | ||
!e.composedPath().includes(modalSearchWrapper[0]) && | ||
!e.composedPath().includes(btnOpenSearch) | ||
) { | ||
modalSearch[0].style.visibility = "hidden"; | ||
modalSearch[0].style.opacity = "0"; | ||
} | ||
}); | ||
|
||
/* click outside end */ | ||
|
||
//! search modal end | ||
} | ||
|
||
function headerFunc(){ | ||
sidebarFunc(); | ||
searchModalFunc(); | ||
} | ||
|
||
export default headerFunc(); |
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,14 @@ | ||
import headerFunc from "./header.js"; | ||
import productsFunc from "./products.js"; | ||
|
||
//! add product to localStorage | ||
async function getData() { | ||
const photos = await fetch("../../js/data.json"); /* !!!!!!!!!! */ | ||
const data = await photos.json(); | ||
|
||
data ? localStorage.setItem("products", JSON.stringify(data)) : []; | ||
} | ||
|
||
getData(); | ||
|
||
const products = localStorage.getItem("products"); |
Oops, something went wrong.