Files
gods-eye-view/src/ui/panelEdge.js
T
Sameh KhamisandManjunath Paparaju d0b614d88e Keep edge mode to the desktop shell and mirror it in right-to-left
Phones and Cockpit keep their own layouts and do not show the switch. The
rails' name panels and edge mode run toward the middle in a right-to-left
language, and the switch reads its side again after the layout moves it.

Co-authored-by: Manjunath Paparaju <[email protected]>
2026-11-14 13:41:07 -08:00

43 lines
1.3 KiB
JavaScript

import { ref } from 'vue';
// Panels can slide over their rail to the screen edge, one setting per side:
// the left column moves onto the left rail, the right column onto the right
// rail. Each panel header has the switch (UiPanelEdge); the choice is kept
// for the next visit and shows as a body class the stylesheet reads.
const KEY = 'gev.panelEdge';
function read() {
try {
const saved = JSON.parse(globalThis.localStorage?.getItem(KEY) || '{}');
return { left: saved.left === true, right: saved.right === true };
} catch {
return { left: false, right: false };
}
}
export const panelEdge = ref(read());
function apply() {
const body = globalThis.document?.body;
if (!body) return;
body.classList.toggle('panels-edge-left', panelEdge.value.left);
body.classList.toggle('panels-edge-right', panelEdge.value.right);
}
apply();
/** Which side a panel element sits on, from the column it is in. */
export function panelSide(element) {
return element?.closest?.('#right-context-rail, #cockpit-utility-controls')
? 'right'
: 'left';
}
export function togglePanelEdge(side) {
panelEdge.value = { ...panelEdge.value, [side]: !panelEdge.value[side] };
try {
globalThis.localStorage?.setItem(KEY, JSON.stringify(panelEdge.value));
} catch {
// Without storage the choice lasts for this visit.
}
apply();
}