From 29bfaa5c5bbfdcdfc2914e599ef92e67a96336b9 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Mon, 13 May 2024 19:42:28 +0530 Subject: [PATCH 1/2] Move download button to end of tile - Changed the position of download button to the end of tile and added a proper download icon to it. When the button is hovered it becomes darker. - Also internationalized the "Download" text on the modal download widget and added download size information to it. --- static/resources_list.txt | 1 + static/skin/download-white.svg | 6 +++ static/skin/index.css | 67 ++++++++++++++++++++++------------ static/skin/index.js | 23 ++++++++++-- test/library_server.cpp | 2 +- test/server.cpp | 13 ++++--- 6 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 static/skin/download-white.svg diff --git a/static/resources_list.txt b/static/resources_list.txt index 755fc5942..8e14c92c2 100644 --- a/static/resources_list.txt +++ b/static/resources_list.txt @@ -4,6 +4,7 @@ skin/magnet.png skin/feed.svg skin/langSelector.svg skin/download.png +skin/download-white.svg skin/hash.png skin/search-icon.svg skin/iso6391To3.js diff --git a/static/skin/download-white.svg b/static/skin/download-white.svg new file mode 100644 index 000000000..ed0356db0 --- /dev/null +++ b/static/skin/download-white.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/static/skin/index.css b/static/skin/index.css index e181ef1cf..ff90b5711 100644 --- a/static/skin/index.css +++ b/static/skin/index.css @@ -152,23 +152,24 @@ .book__link { text-decoration: none; - grid-column: 1 / 3; - grid-row: 1 / 3; } .book__wrapper { + --tile-width: 250px; + --tile-border-width: 1px; + --tile-border-radius: 3px; color: #444343; - height: 248px; - width: 250px; + height: 258px; + width: var(--tile-width); margin: 15px; background-color: #f7f7f7; - border: 1px solid #ececec; - border-radius: 3px; - display: grid; - grid-template-columns: 65px 1fr; - grid-template-rows: 70px 120px 1fr 1fr; - grid-gap: 5px; + border: var(--tile-border-width) solid #ececec; + border-radius: var(--tile-border-radius); + display: flex; + flex-direction: column; + justify-content: space-between; transition: transform 0.25s; + gap: 4px; } .book__wrapper:hover { @@ -177,8 +178,12 @@ .book__link__wrapper { display: grid; + grid-template-areas: + "bookIcon bookHeader" + "bookDesc bookDesc" + ; grid-template-columns: 65px 1fr; - grid-template-rows: 70px 120px 1fr 1fr; + grid-template-rows: 70px 120px; } .book__icon { @@ -192,6 +197,7 @@ width: 48px; height: 48px; margin: 10px 0 0 10px; + grid-area: bookIcon; } .book__header { @@ -203,6 +209,7 @@ height: 100%; align-items: center; align-content: center; + grid-area: bookHeader; } .book__title { @@ -213,28 +220,36 @@ } .book__download { - font-size: 1.1rem; - margin: 3px 0; + cursor: pointer; + font-size: 1.2rem; + background: #00b4e4; + padding: 8px; + border-radius: 0 0 var(--tile-border-radius) var(--tile-border-radius); + display: flex; + align-items: center; + justify-content: center; + position: relative; + width: var(--tile-width); + left: calc(0px - var(--tile-border-width)); +} + +.book__download > img { + height: 16px; + width: 16px; } .book__download > span { - cursor: pointer; text-decoration: none; position: relative; - padding: 0 3px 1px; font-family: roboto; - background: #00b4e4; color: white; - box-shadow: 0 0 0 0; - border-radius: 2px; } -.book__download > span:hover { - box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1) +.book__download:hover { + background: royalblue; } .book__description { - grid-column: 1 / 3; margin: 10px 10px 5px; overflow: hidden; display: -webkit-box; @@ -245,6 +260,13 @@ font-size: 1.2rem; color: #4d4d4d; line-height: 1.25; + grid-area: bookDesc; +} + +.book__meta { + display: flex; + justify-content: space-between; + padding: 0 10px 4px; } .book__languageTag { @@ -257,7 +279,6 @@ color: black; height: 25px; width: 25px; - margin: 10px auto 0 10px; border-radius: 5px; font-size: 0.85rem; } @@ -268,8 +289,6 @@ font-size: 1.1rem; justify-content: flex-end; font-family: roboto; - margin-right: 10px; - margin-top: 10px; overflow: hidden; } diff --git a/static/skin/index.js b/static/skin/index.js index 873b187f0..c4e40d225 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -139,6 +139,19 @@ return spanElement.outerHTML; } + function downloadButtonText(zimSize) { + return $t("download") + (zimSize ? ` - ${zimSize}`: ''); + } + + function downloadButtonHtml(url, zimSize) { + return url + ? `
+ + ${downloadButtonText(zimSize)} +
` + : ''; + } + function generateBookHtml(book, sort = false) { const link = book.querySelector('link[type="text/html"]').getAttribute('href'); let iconUrl; @@ -183,6 +196,7 @@ } const faviconAttr = iconUrl != undefined ? `style="background-image: url('${iconUrl}')"` : ''; const languageAttr = langCode != '' ? `title="${language}" aria-label="${language}"` : 'style="background-color: transparent"'; + divTag.innerHTML = `
@@ -190,13 +204,15 @@
${title}
- ${downloadLink ? `
${$t("download")} ${humanFriendlyZimSize ? ` - ${humanFriendlyZimSize}
`: ''}` : ''}
${description}
+
${getLanguageCodeToDisplay(langCode)}
${tagHtml}
+
+ ${downloadButtonHtml(downloadLink, humanFriendlyZimSize)} `; return divTag; } @@ -282,6 +298,7 @@ } function insertModal(button) { + const downloadSize = button.getAttribute('data-size'); const downloadLink = button.getAttribute('data-link'); button.addEventListener('click', async (event) => { event.preventDefault(); @@ -291,7 +308,7 @@