]> git.zndr.dk Git - zndr-11ty.git/commitdiff
Enter open card
authorJannik ZANDER <jzander@grundfos.com>
Tue, 9 Sep 2025 18:58:06 +0000 (20:58 +0200)
committerJannik ZANDER <jzander@grundfos.com>
Tue, 9 Sep 2025 18:58:06 +0000 (20:58 +0200)
site/assets/styles.css
site/index.njk

index aaaab26a096d44044546803422552f8f3cf0cc46..9ec4b7fbe3622b5ae129383ac455e0e531af33cd 100644 (file)
@@ -40,6 +40,9 @@ body{
   color: var(--fg);
 }
 
+/* Reserve scrollbar space so layout doesn't shift between pages */
+html { scrollbar-gutter: stable both-edges; }
+
 /* =================
    Layout
    ================= */
index 064beb57b6963e59ca25ee3b9254b00f8b8c6032..ee2d56f54c651d90b6e1003426c632f4bda761bf 100644 (file)
@@ -78,6 +78,39 @@ title: zndr.dk — Services
 })();
 </script>
 
+<script>
+(() => {
+  const input = document.getElementById('filter');
+  const cards = Array.from(document.querySelectorAll('.grid a.card')); // anchors
+
+  // ... your existing code (empty node, apply(), etc.) ...
+
+  input.addEventListener('keydown', (e) => {
+    if (e.key !== 'Enter') return;
+
+    // Prevent form-like submission/reload
+    e.preventDefault();
+
+    // Find currently visible cards
+    const visible = cards.filter(c =>
+      c.offsetParent !== null && c.style.display !== 'none'
+    );
+
+    // If exactly one match, go to it
+    if (visible.length === 1) {
+      window.location.href = visible[0].href;
+    }
+    // Optional: if multiple, jump to the first one (comment out if you don't want this)
+    // else if (visible.length > 0) {
+    //   window.location.href = visible[0].href;
+    // }
+  });
+
+  // ... keep your existing apply() and initial call ...
+})();
+</script>
+
+
 <script>
 (function () {
   const PING_URL = "https://lan.zndr.dk/ping";   // 200 only on LAN