Move the task picker into the right pane and drop the switcher from it
This commit is contained in:
Vendored
+7
-9
@@ -1,11 +1,9 @@
|
||||
import { post } from "./api.js";
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { openSettings } from "./settings.js";
|
||||
import { activeTasks, currentSession, findTask, focusedProject, focusProject, focusTab, focusTask, lastVisits, onEach, state } from "./state.js";
|
||||
import { activeTasks, currentSession, focusedProject, focusProject, focusTab, focusTask, lastVisits, onEach, state } from "./state.js";
|
||||
import { openStatus } from "./status.js";
|
||||
export function mountNavbar(root) {
|
||||
const crumb = h("button", { class: "crumb", title: "Switch task (⌘K)" });
|
||||
crumb.onclick = openSwitcher;
|
||||
const status = h("button", { class: "nav-link" }, "Status");
|
||||
status.onclick = openStatus;
|
||||
const settings = h("button", { class: "nav-link" }, "Settings");
|
||||
@@ -14,16 +12,13 @@ export function mountNavbar(root) {
|
||||
const connLabel = h("span", { class: "connection-label" }, "reconnecting…");
|
||||
const me = h("span", { class: "me" });
|
||||
const render = () => {
|
||||
const task = state.selectedTaskId ? findTask(state.selectedTaskId) : undefined;
|
||||
const project = focusedProject();
|
||||
replace(crumb, task ? `${project?.name ?? ""} ▸ ${task.title}` : (project?.name ?? "No task"), " ▾");
|
||||
conn.className = state.connected ? "connection up" : "connection down";
|
||||
conn.title = state.connected ? "live" : "reconnecting";
|
||||
connLabel.hidden = state.connected;
|
||||
replace(me, state.me?.display_name ?? "");
|
||||
};
|
||||
onEach(["me", "projects", "tasks", "selection", "focus", "connection"], render);
|
||||
replace(root, h("a", { href: "#/", class: "brand" }, "byre"), crumb, h("span", { class: "spacer" }), status, settings, connLabel, conn, me);
|
||||
onEach(["me", "connection"], render);
|
||||
replace(root, h("a", { href: "#/", class: "brand" }, "byre"), h("span", { class: "spacer" }), status, settings, connLabel, conn, me);
|
||||
render();
|
||||
addEventListener("keydown", (e) => {
|
||||
if (!(e.metaKey || e.ctrlKey) || document.querySelector("dialog[open]")) {
|
||||
@@ -39,7 +34,7 @@ export function mountNavbar(root) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function openSwitcher() {
|
||||
export function openSwitcher() {
|
||||
if (document.querySelector(".switcher")) {
|
||||
return;
|
||||
}
|
||||
@@ -139,6 +134,9 @@ function openSwitcher() {
|
||||
}
|
||||
};
|
||||
backdrop.onclick = close;
|
||||
const anchor = document.querySelector(".task-picker").getBoundingClientRect();
|
||||
box.style.top = `${anchor.bottom + 4}px`;
|
||||
box.style.right = `${document.documentElement.clientWidth - anchor.right}px`;
|
||||
document.body.append(backdrop, box);
|
||||
render();
|
||||
input.focus();
|
||||
|
||||
Reference in New Issue
Block a user