From 319c7cac8caff1a44fae2bfba4937502e00a4da4 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 28 Oct 2022 12:14:18 +0200 Subject: [PATCH] add style and button logic --- src/public/js/main.js | 20 ++++++++++++----- src/public/styles/style.css | 43 +++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/public/js/main.js b/src/public/js/main.js index 39f9058..55a00dd 100644 --- a/src/public/js/main.js +++ b/src/public/js/main.js @@ -85,23 +85,27 @@ const send = (file, element) => { let url = window.location.href.split("/"); url.pop(); url.push("file"); + let link = `${url.join("/")}/${req.responseText.slice( + 1, + -2 + )}/${pub_key[0]}:${pub_key[1]}`; let main_div = element.parentElement.parentElement; main_div.textContent = ""; let div = document.createElement("DIV"); - div.textContent = "Fichier prêt !"; div.className = "link-area"; main_div.appendChild(div); + let div_title = document.createElement("H4"); + div_title.textContent = "Fichier prêt !"; + div.appendChild(div_title); + let message = document.createElement("P"); message.innerHTML = `Copiez le lien pour télécharger ${file.name}`; div.appendChild(message); let input = document.createElement("INPUT"); - input.value = `${url.join("/")}/${req.responseText.slice( - 1, - -2 - )}/${pub_key[0]}:${pub_key[1]}`; + input.value = link; input.readOnly = true; div.appendChild(input); @@ -109,6 +113,12 @@ const send = (file, element) => { let button = document.createElement("BUTTON"); button.textContent = "Copier le lien"; div.appendChild(button); + + button.addEventListener("click", () => { + navigator.clipboard + .writeText(link) + .then(() => (button.textContent = "Lien copié !")); + }); } else { console.error("Upload failed."); } diff --git a/src/public/styles/style.css b/src/public/styles/style.css index d734f8e..bd42cc0 100644 --- a/src/public/styles/style.css +++ b/src/public/styles/style.css @@ -15,6 +15,7 @@ --border: rgb(45, 40, 22); --area-hover: rgb(184, 150, 48); --font-size: 17px; + --font: Rilu; } } @@ -27,6 +28,7 @@ --border: rgb(213, 202, 168); --area-hover: rgb(223, 193, 99); --font-size: 17px; + --font: Rilu; } } @@ -38,7 +40,7 @@ html { background-color: var(--bg-color); color: var(--text-color); - font-family: Rilu; + font-family: var(--font); font-size: var(--font-size); scroll-behavior: smooth; } @@ -105,13 +107,50 @@ main { padding-left: 1em; } +.link-area > input { + border-radius: 6px; + border: 2px solid var(--shadow); + width: 49%; + height: 3vh; + margin: 0.5vw; + background-color: var(--bg-color); + color: var(--text-color); + font-family: var(--font); + font-size: calc(var(--font-size) - 5px); +} + +.link-area > input:focus { + border: 2px solid var(--border); + outline: none; +} + +.link-area > button { + border-radius: 6px; + border: 2px solid var(--shadow); + width: 50%; + height: 5vh; + background-color: var(--bg-color); + color: var(--text-color); + font-family: var(--font); + font-size: var(--font-size); + transition-duration: 0.4s; + cursor: pointer; +} + +.link-area > button:hover { + background-color: var(--text-color); + color: var(--bg-color); + box-shadow: 0 4px 15px 0 var(--shadow), 0 4px 15px 0 var(--shadow); +} + /* Mobile display */ @media only screen and (max-height: 850px) { header > .text-title { font-size: 1.5rem; } - .upload-area { + .upload-area, + .link-area { height: 65vh; } }