From f4601a782be693644a11c6f267872454fcc8b701 Mon Sep 17 00:00:00 2001 From: exyi Date: Tue, 29 Sep 2020 14:37:54 +0000 Subject: [PATCH 1/2] Implement simple routing for TaskPanel --- frontend/src/App.svelte | 7 ++++--- frontend/src/TaskPanel.svelte | 16 +++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 71d4f4d..3631f9a 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -15,8 +15,9 @@ import type { detach } from "svelte/internal"; // react to hash changes let hash = window.location.hash.substr(1); window.onhashchange = () => { - hash = window.location.hash.substr(1); + hash = window.location.hash.substr(1); } + $: selectedTaskId = (/^task\/([^\/]*)/.exec(hash) || [null, null])[1]
selectedTask && select(selectedTask)}> + on:click={() => location.hash = `#task/${selectedTask?.id}`}>
From e9a6ccb59c02645f1b07d9d8d10eddddffe1a50f Mon Sep 17 00:00:00 2001 From: exyi Date: Tue, 29 Sep 2020 19:30:04 +0000 Subject: [PATCH 2/2] Merge master --- frontend/src/TaskPanel.svelte | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/frontend/src/TaskPanel.svelte b/frontend/src/TaskPanel.svelte index de12775..c4e9782 100644 --- a/frontend/src/TaskPanel.svelte +++ b/frontend/src/TaskPanel.svelte @@ -8,7 +8,7 @@ import TaskDisplay from "./TaskDisplay.svelte"; let selectedTask: TaskDescriptor | null = null export let selectedTaskId: string | null = null - let heightClass: "collapsed" | "full" | "preview" = "collapsed" + let heightClass: "closed" | "collapsed" | "full" | "preview" = "collapsed" export function preSelect(task: TaskDescriptor) { if (heightClass != "full") { @@ -36,13 +36,19 @@ import TaskDisplay from "./TaskDisplay.svelte"; function close() { location.hash = "" - heightClass = "collapsed" + heightClass = "closed" window.setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }), 100) } + + function handleKeydown(e: KeyboardEvent) { + if (e.key === "Escape") { + close() + } + } + +
location.hash = `#task/${selectedTask?.id}`}>