]> git.ardis.lu - static-encrypt/commitdiff
Add popover transition out
authorArdis Lu <ardisglu@gmail.com>
Sun, 15 Oct 2023 03:28:17 +0000 (20:28 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 15 Oct 2023 03:28:17 +0000 (20:28 -0700)
index.html

index 7c4401aa0202c36c53057655b833a1c3e4e65afa..eb9171e5b83ae9c91a34d30b9f3c1b15c66bc06f 100644 (file)
       position: relative;
     }
 
+    .copied::before,
+    .copied::after {
+      display: var(--display, none);
+      position: absolute;
+      background: hsl(216deg 50% 90%);
+      pointer-events: none;
+      opacity: var(--opacity, 0);
+      transition: opacity 200ms;
+    }
+
     .copied::before {
       content: '';
-      position: absolute;
       inset-inline-start: calc(100% - 4px);
       inset-block-start: calc(50% - 4px);
       inline-size: 10px;
       block-size: 10px;
-      background: hsl(216deg 50% 90%);
       clip-path: polygon(0 50%, 100% 0, 100% 100%);
     }
 
     .copied::after {
       content: 'Copied!';
-      position: absolute;
       inset-inline-start: calc(100% + 4px);
       font-weight: 700;
-      background: hsl(216deg 50% 90%);
       padding: 8px;
       border-radius: 4px;
     }
         <label for="output">Encrypted content</label>
         <div class="ciphertext-container">
           <pre id="ciphertext" readonly></pre>
-          <button id="copy" class="icon-button">
+          <button id="copy" class="icon-button copied">
             <svg aria-labelledby="clipboard" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
               <title id="clipboard">Copy to clipboard</title>
               <rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect>
       e.preventDefault();
       const ciphertext = document.querySelector('#ciphertext').textContent;
       navigator.clipboard.writeText(ciphertext);
-      copyButton.classList.add('copied');
-      setTimeout(() => copyButton.classList.remove('copied'), 2000);
+      copyButton.style.setProperty('--display', 'inline');
+      copyButton.style.setProperty('--opacity', 1);
+      setTimeout(() => copyButton.style.setProperty('--opacity', 0), 2000);
+      setTimeout(() => copyButton.style.setProperty('--display', 'none'), 2500);
     })
 
     document.querySelector('#download').addEventListener('click', e => {
This page took 0.04668 seconds and 4 git commands to generate.