minor change in UI

This commit is contained in:
Manan Jethwani 2021-07-06 08:43:42 +05:30 committed by Emmanuel Engelhart
parent 6e8200637e
commit ad7a63a471
3 changed files with 65 additions and 54 deletions

View File

@ -23,15 +23,15 @@ body {
.kiwixNav { .kiwixNav {
background-color: #f4f6f8; background-color: #f4f6f8;
width: 100%; width: 100%;
padding: 20px 11vw; padding: 20px 11vw 25px;
height: 200px; height: 140px;
} }
.kiwixHomeBody__results { .kiwixHomeBody__results {
font-size: 1.6rem; font-size: 1.6rem;
color: #333333; color: #333333;
font-family: poppins; font-family: poppins;
margin: 10px 0; margin: 10px 0 -5px;
position: relative; position: relative;
top: -10px; top: -10px;
left: 13px; left: 13px;
@ -73,16 +73,16 @@ body {
width: 231px; width: 231px;
height: 35px; height: 35px;
line-height: 3; line-height: 3;
background: #627B93; background: #909090;
overflow: hidden; overflow: hidden;
border-radius: 10px; border-radius: 10px;
border: 1px solid #394856; border: 1px solid #b5b2b2;
} }
.kiwixNav__select::after { .kiwixNav__select::after {
content: '\25BC'; content: '\25BC';
color: #fff; color: #fff;
background-color: #627B93; background-color: #909090;
height: 100%; height: 100%;
position: absolute; position: absolute;
top: 0; top: 0;
@ -95,6 +95,11 @@ body {
transition: .25s all ease; transition: .25s all ease;
} }
.kiwixNav__kiwixFilter option {
background-color: #fff;
color: #000;
}
.kiwixSearch { .kiwixSearch {
height: 35px; height: 35px;
width: 229px; width: 229px;
@ -114,17 +119,17 @@ body {
width: 100px; width: 100px;
border-radius: 10px; border-radius: 10px;
color: white; color: white;
background-color: #627B93; background-color: #909090;
border: solid 1px #b5b2b2; border: solid 1px #b5b2b2;
} }
.searchButton:hover { .searchButton:hover {
background-color: #4f6478; background-color: #858585;
} }
.kiwixHomeBody { .kiwixHomeBody {
padding: 20px 15vw; padding: 20px 15vw;
min-height: calc(100vh - 230px); min-height: calc(100vh - 170px);
position: relative; position: relative;
} }
@ -202,6 +207,7 @@ body {
font-weight: 300; font-weight: 300;
font-size: 1.2rem; font-size: 1.2rem;
color: #4d4d4d; color: #4d4d4d;
line-height: 1.25;
} }
.book__languageTag { .book__languageTag {
@ -257,26 +263,8 @@ body {
font-family: roboto; font-family: roboto;
} }
.book__links > a::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
transform: scaleY(0);
transform-origin: bottom center;
background: #00b4e4;
color: white;
z-index: -1;
transition: transform 0.2s;
}
.book__links > a:hover::after {
transform: scaleY(1);
}
.book__links > a:hover { .book__links > a:hover {
background: #00b4e4;
color: white; color: white;
} }
@ -349,38 +337,38 @@ body {
@media screen and (max-width: 1100px) { @media screen and (max-width: 1100px) {
.kiwixNav {
height: 250px;
}
.kiwixHomeBody { .kiwixHomeBody {
padding: 20px 10vw; padding: 20px 10vw;
min-height: calc(100vh - 280px); min-height: calc(100vh - 170px);
} }
.kiwixNav__filters { .kiwixNav__filters {
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(4, 1fr);
} }
} }
@media screen and (max-width: 650px) { @media screen and (max-width: 590px) {
.kiwixNav { .kiwixNav {
height: 350px; height: 257px;
} }
.kiwixHomeBody { .kiwixHomeBody {
min-height: calc(100vh - 380px); min-height: calc(100vh - 287px);
}
.kiwixSearch {
margin-top: 11px;
}
.searchButton {
margin: 19px 0;
width: 229px;
} }
.kiwixNav__filters { .kiwixNav__filters {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.searchButton {
margin: 17px 0;
width: 229px;
}
} }
@media screen and (max-width: 340px) { @media screen and (max-width: 340px) {

View File

@ -129,7 +129,12 @@
} else { } else {
toggleFooter(); toggleFooter();
} }
document.querySelector('.kiwixHomeBody__results').innerHTML = `${results} books` const kiwixResultText = document.querySelector('.kiwixHomeBody__results')
if (results) {
kiwixResultText.innerHTML = `${results} books`;
} else {
kiwixResultText.innerHTML = ``;
}
loader.style.display = 'none'; loader.style.display = 'none';
return books; return books;
}); });
@ -160,7 +165,14 @@
window.history.pushState({}, null, `${window.location.href.split('?')[0]}?lang=`); window.history.pushState({}, null, `${window.location.href.split('?')[0]}?lang=`);
setCookie(filterCookieName, 'lang='); setCookie(filterCookieName, 'lang=');
resetAndFilter(); resetAndFilter();
filterTypes.forEach(key => {document.getElementsByName(key)[0].value = params.get(key) || ''}); document.querySelectorAll('.filter').forEach(filter => {
filter.value = params.get(filter.name) || '';
if (filter.value) {
filter.style = 'background-color: #858585; color: #fff';
} else {
filter.style = 'background-color: #ffffff; color: black';
}
})
}; };
loader.setAttribute('style', 'position: absolute; top: 50%'); loader.setAttribute('style', 'position: absolute; top: 50%');
}, 300); }, 300);
@ -216,22 +228,23 @@
bookOrderMap.clear(); bookOrderMap.clear();
params = new URLSearchParams(window.location.search); params = new URLSearchParams(window.location.search);
if (filterType) { if (filterType) {
const filter = document.getElementsByName(filterType)[0];
if (filterValue) {
filter.style = 'background-color: #4f6478; color: #fff';
} else {
filter.style = 'background-color: #ffffff; color: black';
}
params.set(filterType, filterValue); params.set(filterType, filterValue);
window.history.pushState({}, null, `${window.location.href.split('?')[0]}?${params.toString()}`); window.history.pushState({}, null, `${window.location.href.split('?')[0]}?${params.toString()}`);
setCookie(filterCookieName, params.toString()); setCookie(filterCookieName, params.toString());
} }
document.querySelectorAll('.filter').forEach(filter => {
if (filter.value) {
filter.style = 'background-color: #858585; color: #fff';
} else {
filter.style = 'background-color: #ffffff; color: black';
}
});
await loadAndDisplayBooks(true); await loadAndDisplayBooks(true);
} }
window.addEventListener('popstate', async () => { window.addEventListener('popstate', async () => {
await resetAndFilter(); await resetAndFilter();
filterTypes.forEach(key => {document.getElementsByName(key)[0].value = params.get(key) || ''}); document.querySelectorAll('.filter').forEach(filter => {filter.value = params.get(filter.name) || ''});
}); });
async function loadSubset() { async function loadSubset() {
@ -277,6 +290,9 @@
await loadAndDisplayBooks(); await loadAndDisplayBooks();
await loadAndDisplayOptions('#languageFilter', langList); await loadAndDisplayOptions('#languageFilter', langList);
await loadAndDisplayOptions('#categoryFilter', categoryList); await loadAndDisplayOptions('#categoryFilter', categoryList);
document.querySelectorAll('.filter').forEach(filter => {
filter.addEventListener('change', () => {resetAndFilter(filter.name, filter.value)});
});
filterTypes.forEach((filter) => { filterTypes.forEach((filter) => {
const filterTag = document.getElementsByName(filter)[0]; const filterTag = document.getElementsByName(filter)[0];
filterTag.addEventListener('change', () => {resetAndFilter(filterTag.name, filterTag.value)}); filterTag.addEventListener('change', () => {resetAndFilter(filterTag.name, filterTag.value)});
@ -292,6 +308,13 @@
langFilter.value = browserLang.length === 3 ? browserLang : iso6391To3[browserLang]; langFilter.value = browserLang.length === 3 ? browserLang : iso6391To3[browserLang];
langFilter.dispatchEvent(new Event('change')); langFilter.dispatchEvent(new Event('change'));
} }
document.querySelectorAll('.filter').forEach(filter => {
if (filter.value) {
filter.style = 'background-color: #858585; color: #fff';
} else {
filter.style = 'background-color: #ffffff; color: black';
}
});
setCookie(filterCookieName, params.toString()); setCookie(filterCookieName, params.toString());
} }
})(); })();

View File

@ -48,18 +48,18 @@
<div class='kiwixNav'> <div class='kiwixNav'>
<div class="kiwixNav__filters"> <div class="kiwixNav__filters">
<div class="kiwixNav__select"> <div class="kiwixNav__select">
<select name="lang" id="languageFilter" class='kiwixNav__kiwixFilter'> <select name="lang" id="languageFilter" class='kiwixNav__kiwixFilter filter'>
<option value="" selected>All languages</option> <option value="" selected>All languages</option>
</select> </select>
</div> </div>
<div class="kiwixNav__select"> <div class="kiwixNav__select">
<select name="category" id="categoryFilter" class='kiwixNav__kiwixFilter'> <select name="category" id="categoryFilter" class='kiwixNav__kiwixFilter filter'>
<option value="" selected>All categories</option> <option value="" selected>All categories</option>
</select> </select>
</div> </div>
</div> </div>
<form id='kiwixSearchForm' class='kiwixNav__SearchForm'> <form id='kiwixSearchForm' class='kiwixNav__SearchForm'>
<input type="text" name="q" placeholder="Search" id="searchFilter" class='kiwixSearch'> <input type="text" name="q" placeholder="Search" id="searchFilter" class='kiwixSearch filter'>
<input type="submit" class="searchButton" value="Search"/> <input type="submit" class="searchButton" value="Search"/>
</form> </form>
</div> </div>