Skip to content

Commit

Permalink
change empty page
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuSchaff committed Jan 1, 2022
1 parent ab01b3b commit 5101fa9
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 20 deletions.
Binary file added Algo simplifié visuellement.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<h1 class="header-title">Les petits plats</h1>
</header>
<div class="search">
<form id="searchMain" action="" id="form">
<form action="" id="form">
<input
id="searchBar"
class="searchInput"
Expand Down
7 changes: 7 additions & 0 deletions sass/layout/_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@
line-height: 14px;
letter-spacing: 0em;
}
.emptyPage {
grid-column-start: 2;
font-size: 18px;
font-style: normal;
font-weight: 400;
margin-top: 200px;
}
13 changes: 6 additions & 7 deletions sass/layout/_nav.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.search {
width: 100%;
}
form {
#form {
outline: none;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
#searchBar {
height: 69px;
Expand All @@ -15,12 +19,7 @@ form {
outline: none;
}
}
#searchMain {
display: flex;
justify-content: center;
align-items: center;
position: relative;
}

.searchIcon {
position: absolute;
top: 50%;
Expand Down
4 changes: 3 additions & 1 deletion src/buildCooking.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ function createPage(recipes2) {
return vnode;
}
function createEmptyPage() {
const vnode = m("div", { className: "main-wrapper" }, [""]);
const vnode = m("div", { className: "main-wrapper" }, [
m("div", { className: "emptyPage" }, ["Aucun résultat n'a été trouvé"]),
]);
return vnode;
}
9 changes: 7 additions & 2 deletions src/globalFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ function updateDomWithTags() {
sortedArray = searchMainInput(sortedArray, input.value.toLowerCase());
}
sortedArray = triTagAll(sortedArray);
let newVnode = createPage(sortedArray);
patch(page, newVnode);
if (sortedArray.length === 0) {
let emptyPage = createEmptyPage();
patch(page, emptyPage);
} else {
let newVnode = createPage(sortedArray);
patch(page, newVnode);
}
}
20 changes: 13 additions & 7 deletions src/searchMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ const tags = {
};
let page;
let sortedArray = Array.from(recipes);
function initPage() {
const vnode = createPage(sortedArray);
page = createElement(vnode);
document.querySelector(".body").insertAdjacentElement("beforeend", page);
}
initPage();
// Selectionne l'input ingredient
const ingredientInput = document.getElementById("ingredientInput");
const appareilInput = document.getElementById("appareilInput");
const ustensilsInput = document.getElementById("ustensilsInput");
// Selectionne tous les inputs
const inputsTag = document.querySelectorAll(".tagInput");

function initPage() {
const vnode = createPage(sortedArray);
page = createElement(vnode);
document.querySelector(".body").insertAdjacentElement("beforeend", page);
}
initPage();

function simpleResearch(value) {
if (
!(
Expand All @@ -44,13 +45,18 @@ input.addEventListener("input", (e) => {
// alors va essayer de matcher avec
sortedArray = Array.from(recipes);
page = document.querySelector(".main-wrapper");
if (document.querySelector(".emptyPage")) {
return;
}

if (e.target.value.length >= 3) {
sortedArray = simpleResearch(e.target.value);
if (sortedArray.length > 0) {
let vnode = createPage(sortedArray);
patch(page, vnode);
} else {
patch(page, createEmptyPage());
let emptyPage = createEmptyPage();
patch(page, emptyPage);
}
} else {
sortedArray = triTagAll(sortedArray);
Expand Down

0 comments on commit 5101fa9

Please sign in to comment.