2026-10-14 21:06:30 -07:00
|
|
|
import { mountAdmin } from "./admin.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";
|
|
|
|
|
import { mountInbox } from "./inbox.js";
|
2026-10-14 21:25:01 -07:00
|
|
|
import { mountSettings } from "./settings.js";
|
2026-10-14 09:40:12 -07:00
|
|
|
import { mountTranscript } from "./task.js";
|
|
|
|
|
import { mountTasks } from "./tasks.js";
|
|
|
|
|
const views = {
|
|
|
|
|
transcript: { label: "Transcript", mount: mountTranscript },
|
2026-10-14 19:35:34 -07:00
|
|
|
changes: { label: "Changes", mount: (root) => mountChanges(root) },
|
2026-10-14 09:40:12 -07:00
|
|
|
tasks: { label: "Tasks", mount: mountTasks },
|
|
|
|
|
inbox: { label: "Inbox", mount: mountInbox },
|
2026-10-14 21:06:30 -07:00
|
|
|
admin: { label: "Admin", mount: mountAdmin },
|
2026-10-14 21:25:01 -07:00
|
|
|
settings: { label: "Settings", mount: mountSettings },
|
2026-10-14 09:40:12 -07:00
|
|
|
};
|
2026-10-14 21:25:01 -07:00
|
|
|
const order = ["transcript", "changes", "tasks", "inbox", "admin", "settings"];
|
2026-10-14 22:28:25 -07:00
|
|
|
const panes = [];
|
|
|
|
|
export function openTranscript() {
|
|
|
|
|
if (panes.some((p) => p.current() === "transcript")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
(panes.find((p) => p.current() !== "tasks") ?? panes[0])?.show("transcript");
|
|
|
|
|
}
|
2026-10-14 09:40:12 -07:00
|
|
|
export class Pane {
|
|
|
|
|
key;
|
|
|
|
|
el;
|
|
|
|
|
tabs;
|
|
|
|
|
body;
|
|
|
|
|
view;
|
|
|
|
|
dispose = () => { };
|
|
|
|
|
constructor(key, fallback) {
|
|
|
|
|
this.key = key;
|
|
|
|
|
this.tabs = h("nav", { class: "pane-tabs" });
|
|
|
|
|
this.body = h("div", { class: "pane-body" });
|
|
|
|
|
this.el = h("section", { class: "pane" }, this.tabs, this.body);
|
|
|
|
|
const saved = localStorage.getItem(this.storageKey());
|
|
|
|
|
this.view = saved && saved in views ? saved : fallback;
|
|
|
|
|
this.show(this.view);
|
2026-10-14 22:28:25 -07:00
|
|
|
panes.push(this);
|
|
|
|
|
}
|
|
|
|
|
current() {
|
|
|
|
|
return this.view;
|
2026-10-14 09:40:12 -07:00
|
|
|
}
|
|
|
|
|
show(view) {
|
|
|
|
|
this.dispose();
|
|
|
|
|
this.view = view;
|
|
|
|
|
localStorage.setItem(this.storageKey(), view);
|
|
|
|
|
replace(this.tabs, ...order.map((v) => {
|
|
|
|
|
const b = h("button", { class: v === view ? "active" : "" }, views[v].label);
|
|
|
|
|
b.onclick = () => this.show(v);
|
|
|
|
|
return b;
|
|
|
|
|
}));
|
2026-10-14 16:03:46 -07:00
|
|
|
const root = h("div", { class: `view view-${view}` });
|
2026-10-14 09:40:12 -07:00
|
|
|
replace(this.body, root);
|
|
|
|
|
this.dispose = views[view].mount(root);
|
|
|
|
|
}
|
|
|
|
|
storageKey() {
|
|
|
|
|
return `byre.pane.${this.key}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//# sourceMappingURL=panes.js.map
|