From 7111ac0a3b05edf864bd93331faedb7e0b11754e Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Thu, 6 Apr 2023 14:24:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Refactor=20shortcuts=20in=20proj?= =?UTF-8?q?ect=20layout=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add shortcuts to project pages - Add date-fns import for date formatting [src/routes/projects/[projectId]/+layout.svelte] - Add `format` import from `date-fns` - Add `Shift+p` shortcut to go to project page - Add `Meta+Shift+p` shortcut to go to project settings page - Add `Shift+r` shortcut to go to project player page - Add `a i p` shortcut to go to AI playground page --- src/routes/projects/[projectId]/+layout.svelte | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/routes/projects/[projectId]/+layout.svelte b/src/routes/projects/[projectId]/+layout.svelte index 78aa028b3..e3cefc896 100644 --- a/src/routes/projects/[projectId]/+layout.svelte +++ b/src/routes/projects/[projectId]/+layout.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import tinykeys from 'tinykeys'; import { derived } from 'svelte/store'; + import { format } from 'date-fns'; export let data: LayoutData; const { project } = data; @@ -40,6 +41,21 @@ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return; $project && goto(`/projects/${$project.id}/terminal/`); }, + 'Shift+p': (event: KeyboardEvent) => { + const target = event.target as HTMLElement; + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return; + $project && goto(`/projects/${$project.id}/`); + }, + 'Meta+Shift+p': (event: KeyboardEvent) => { + const target = event.target as HTMLElement; + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return; + $project && goto(`/projects/${$project.id}/settings/`); + }, + 'Shift+r': (event: KeyboardEvent) => { + const target = event.target as HTMLElement; + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return; + $project && goto(`/projects/${$project.id}/player/${format(new Date(), 'yyyy-MM-dd')}`); + }, 'a i p': () => $project && goto(`/projects/${$project.id}/aiplayground/`) }) );