Browse Source

feat: remove keyboard navigation again

main
Inhji Y. 9 months ago
parent
commit
05d864ec75
  1. 4
      assets/js/app.js
  2. 10
      assets/js/keyboard-navigation.js
  3. 18
      lib/mirage_web/live/page_live.html.leex

4
assets/js/app.js

@ -17,7 +17,6 @@ import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
import initEditor from "./editor.js"
import {keyDownHandler} from "./keyboard-navigation.js"
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
@ -26,9 +25,6 @@ let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToke
window.addEventListener("phx:page-loading-start", info => NProgress.start())
window.addEventListener("phx:page-loading-stop", info => NProgress.done())
// Handle Keypresses for navigation
window.addEventListener("keydown", keyDownHandler)
// connect if there are any LiveViews on the page
liveSocket.connect()

10
assets/js/keyboard-navigation.js

@ -1,10 +0,0 @@
export function keyDownHandler(e) {
switch (e.key) {
case "n":
window.location.href = '/notes';
break;
case "h":
window.location.href = '/';
break;
}
}

18
lib/mirage_web/live/page_live.html.leex

@ -30,20 +30,4 @@
</li>
</ul>
</div>
</section>
<section class="width-full bg-content">
<h2>Keyboard Navigation</h2>
<div class="content html">
<p>This page has some keyboard shortcuts to navigate it.</p>
<dl>
<dt><kbd>n</kbd></dt>
<dd>Navigates to notes</dd>
<dt><kbd>h</kbd></dt>
<dd>Navigates to home</dd>
</dl>
</div>
</section>
</section>
Loading…
Cancel
Save