Add four-icon mobile bottom Dock with recent sections

This commit is contained in:
SantaSpeen committed 2026-12-02 14:56:04 +03:00
1 parent c3257a0f4d
commit 03c590e172
20 files changed
+547 -5

No files matched your search

+42 -1
View File
@@ -5,6 +5,11 @@ import {
} from "../components/search-select.js";
import { createNotifier } from "../components/toast.js";
import { mountCopyField } from "../components/copy-field.js";
import {
mountMobileDock,
createMobileHistory,
mobileDockQuery,
} from "../components/mobile-dock.js";
import {
themeControlMarkup,
mountThemeControl,
@@ -32,6 +37,7 @@ import {
} from "../components/account-pages.js";
import { exportSystem } from "../components/export-system.js";
const identityAdapter = createDemoIdentityAdapter();
const mobileHistory = createMobileHistory();
let preferences = {};
try {
preferences =
@@ -350,6 +356,7 @@ function bindDockHover() {
const nav = $(".navigation");
nav.addEventListener("pointerenter", (e) => {
if (
matchMedia(mobileDockQuery).matches ||
e.pointerType !== "mouse" ||
!matchMedia("(hover: hover) and (pointer: fine)").matches
)
@@ -492,6 +499,40 @@ function render({ preserveDock = false } = {}) {
bindDockHover();
if (dockWasOpen) setDockOpen(true, false);
bindCharts();
if ($(".navigation")) {
const mobile = mountMobileDock($(".navigation"), {
trigger: $(".dock-brand"),
history: mobileHistory,
t,
getPage: (id) => {
const allowed = [
"dashboard",
...accountPageIds,
"components",
"tokens",
"errors",
...(panel === "admin" ? ["users", "settings", "ssh", "logs"] : []),
];
return allowed.includes(id) && pageNames[id]
? {
id,
label: pageNames[id],
icon:
{ ssh: "terminal", logs: "document", errors: "warning" }[id] ||
id,
}
: null;
},
onNavigate: navigate,
onCloseMenu: () => setDockOpen(false, false),
});
mobile.update(page, `${panel}:${currentIdentity()?.sub || "account"}`);
selectCleanups.push(() => mobile.dispose());
} else {
mobileHistory.current = null;
mobileHistory.previous = null;
mobileHistory.context = null;
}
if ($("#account-menu")) {
const submenu = mountAccountSubmenu($("#account-menu"));
selectCleanups.push(() => submenu.dispose());
@@ -1076,7 +1117,7 @@ document.addEventListener("click", async (e) => {
page = pageButton.dataset.page;
if (["ssh", "logs"].includes(page)) administrationOpen = true;
$("#dialog").close();
render({ preserveDock: fromDock });
render({ preserveDock: fromDock && !matchMedia(mobileDockQuery).matches });
if (fromDock && document.body.classList.contains("dock-open")) {
$(".nav-links [aria-current=page]")?.focus({ preventScroll: true });
} else $("#content")?.focus();