2026-10-15 09:40:30 -07:00
|
|
|
import type { TaskTab } from "./api.js";
|
2026-10-14 19:35:34 -07:00
|
|
|
import { mountChanges } from "./changes.js";
|
2026-10-14 09:40:12 -07:00
|
|
|
import { h, replace } from "./dom.js";
|
2026-10-15 07:31:53 -07:00
|
|
|
import { mountFiles } from "./files.js";
|
2026-10-14 09:40:12 -07:00
|
|
|
import { mountInbox } from "./inbox.js";
|
2026-10-15 09:40:30 -07:00
|
|
|
import { mountLead } from "./lead.js";
|
|
|
|
|
import { focusTab, on, state, tabs } from "./state.js";
|
2026-10-14 09:40:12 -07:00
|
|
|
import { mountTranscript } from "./task.js";
|
2026-10-15 07:23:17 -07:00
|
|
|
import { mountTodo } from "./todo.js";
|
2026-10-14 09:40:12 -07:00
|
|
|
|
2026-10-15 09:40:30 -07:00
|
|
|
const views: Record<TaskTab, { label: string; mount: (root: HTMLElement) => () => void }> = {
|
2026-10-14 09:40:12 -07:00
|
|
|
transcript: { label: "Transcript", mount: mountTranscript },
|
2026-10-14 19:35:34 -07:00
|
|
|
changes: { label: "Changes", mount: (root) => mountChanges(root) },
|
2026-10-15 07:31:53 -07:00
|
|
|
files: { label: "Files", mount: mountFiles },
|
2026-10-14 09:40:12 -07:00
|
|
|
inbox: { label: "Inbox", mount: mountInbox },
|
2026-10-15 09:40:30 -07:00
|
|
|
todo: { label: "Todo", mount: mountTodo },
|
2026-10-14 09:40:12 -07:00
|
|
|
};
|
|
|
|
|
|
2026-10-15 09:40:30 -07:00
|
|
|
export function leadPane(): HTMLElement {
|
|
|
|
|
const root = h("div", { class: "view view-lead" });
|
|
|
|
|
mountLead(root);
|
|
|
|
|
return h("section", { class: "pane" }, h("nav", { class: "pane-tabs" }, h("button", { class: "active" }, "Lead")), h("div", { class: "pane-body" }, root));
|
2026-10-15 00:08:32 -07:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 09:40:30 -07:00
|
|
|
export function taskPane(): HTMLElement {
|
|
|
|
|
const strip = h("nav", { class: "pane-tabs" });
|
|
|
|
|
const body = h("div", { class: "pane-body" });
|
|
|
|
|
let shown: TaskTab | undefined;
|
|
|
|
|
let dispose: () => void = () => {};
|
2026-10-14 09:40:12 -07:00
|
|
|
|
2026-10-15 09:40:30 -07:00
|
|
|
const render = () => {
|
|
|
|
|
const first = state.focus.tabs.filter((t, i, all) => tabs.includes(t) && all.indexOf(t) === i);
|
|
|
|
|
const order = [...first, ...tabs.filter((t) => !first.includes(t))];
|
|
|
|
|
const tab = state.focus.tab;
|
2026-10-14 09:40:12 -07:00
|
|
|
replace(
|
2026-10-15 09:40:30 -07:00
|
|
|
strip,
|
|
|
|
|
...order.map((t) => {
|
|
|
|
|
const b = h("button", { class: t === tab ? "active" : "" }, views[t].label);
|
|
|
|
|
b.onclick = () => focusTab(t);
|
2026-10-14 09:40:12 -07:00
|
|
|
return b;
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-10-15 09:40:30 -07:00
|
|
|
if (tab === shown) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dispose();
|
|
|
|
|
shown = tab;
|
|
|
|
|
const root = h("div", { class: `view view-${tab}` });
|
|
|
|
|
replace(body, root);
|
|
|
|
|
dispose = views[tab].mount(root);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
on("focus", render);
|
|
|
|
|
render();
|
|
|
|
|
return h("section", { class: "pane" }, strip, body);
|
2026-10-14 09:40:12 -07:00
|
|
|
}
|