From: Ardis Lu Date: Thu, 23 Feb 2023 04:50:46 +0000 (-0800) Subject: Add copy button X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=bad56d5f16ccc19bc3f943bdd7bd918362d819c6;p=static-encrypt Add copy button --- diff --git a/index.html b/index.html index d784477..0c5b685 100644 --- a/index.html +++ b/index.html @@ -42,7 +42,7 @@ textarea, input, - button, + .text-button, pre { font-family: inherit; font-size: 1rem; @@ -54,7 +54,7 @@ } :is(textarea, input, button, pre):focus-within, - button:hover { + .text-button:hover { border: 1px solid hsl(216deg 50% 70%); filter: drop-shadow(0 0 4px hsl(216deg 50% 80%)); transition: filter 200ms, border 200ms; @@ -68,6 +68,11 @@ block-size: 20rem; } + .ciphertext-container { + display: flex; + gap: 8px; + } + #ciphertext { overflow-x: auto; background: hsl(216deg 50% 90%); @@ -77,10 +82,20 @@ button { inline-size: fit-content; padding: 8px; - background: hsl(216deg 50% 90%); cursor: pointer; } + .text-button { + background: hsl(216deg 50% 90%); + } + + .icon-button { + background: none; + border: none; + padding: 6px 4px; + margin-block-end: 16px; + } + footer { margin-block: 24px 16px; } @@ -89,7 +104,7 @@ color: inherit; } - a>svg { + svg { inline-size: 24px; block-size: 24px; color: inherit; @@ -111,12 +126,24 @@ - + -

-        
+        
+

+          
+        
+
@@ -164,6 +191,12 @@ setOutput(encrypted); }); + document.querySelector('#copy').addEventListener('click', e => { + e.preventDefault(); + const ciphertext = document.querySelector('#ciphertext').textContent; + navigator.clipboard.writeText(ciphertext); + }) + document.querySelector('#download').addEventListener('click', e => { e.preventDefault(); const encrypted = document.querySelector('#ciphertext').textContent;