feat(skin): add local sibling ordering

This commit is contained in:
illusia committed 2026-10-10 15:53:50 +08:00
1 parent 11a07eae0f
commit 1499d60bc0
12 files changed
+78 -15

No files matched your search

+3 -2
View File
@@ -88,10 +88,10 @@ function setVariable(element: HTMLElement, dataFlag: string, variable: string, v
}
function clearLayoutAttributes(element: HTMLElement): void {
for (const key of ["wsLayoutActive", "wsLayoutHidden", "wsLayoutSelected", "wsLayoutForeground", "wsLayoutBackground", "wsLayoutBorder", "wsLayoutRadius", "wsLayoutWidth", "wsLayoutHeight", "wsLayoutTouchTarget"]) {
for (const key of ["wsLayoutActive", "wsLayoutHidden", "wsLayoutSelected", "wsLayoutForeground", "wsLayoutBackground", "wsLayoutBorder", "wsLayoutRadius", "wsLayoutWidth", "wsLayoutHeight", "wsLayoutOrder", "wsLayoutTouchTarget"]) {
delete element.dataset[key];
}
for (const key of ["--ws-layout-x", "--ws-layout-y", "--ws-layout-scale", "--ws-layout-width", "--ws-layout-height", "--ws-layout-foreground", "--ws-layout-background", "--ws-layout-border", "--ws-layout-radius"]) {
for (const key of ["--ws-layout-x", "--ws-layout-y", "--ws-layout-scale", "--ws-layout-order", "--ws-layout-width", "--ws-layout-height", "--ws-layout-foreground", "--ws-layout-background", "--ws-layout-border", "--ws-layout-radius"]) {
element.style.removeProperty(key);
}
}
@@ -147,6 +147,7 @@ function applyRoot(root: HTMLElement): void {
else element.style.removeProperty("--ws-layout-y");
if (placement.scale !== undefined) element.style.setProperty("--ws-layout-scale", String(placement.scale));
else element.style.removeProperty("--ws-layout-scale");
setVariable(element, "wsLayoutOrder", "--ws-layout-order", placement.order === undefined ? undefined : String(placement.order));
setVariable(element, "wsLayoutWidth", "--ws-layout-width", placement.width === undefined ? undefined : placement.width + "px");
setVariable(element, "wsLayoutHeight", "--ws-layout-height", placement.height === undefined ? undefined : placement.height + "px");
setVariable(element, "wsLayoutForeground", "--ws-layout-foreground", placement.foreground);
+2 -1
View File
@@ -84,9 +84,10 @@ test("version 2 layout overrides can be saved, loaded, and cleared per skin", ()
withLocalStorage((storage) => {
saveSkinLayoutOverrides("community.illusia-voice", {
schemaVersion: 1,
pages: { home: { mobile: { "home.header": { x: 8, visible: true } } } },
pages: { home: { mobile: { "home.header": { x: 8, visible: true, order: 2 } } } },
});
assert.equal(loadSkinLayoutOverrides("community.illusia-voice").pages.home?.mobile?.["home.header"]?.x, 8);
assert.equal(loadSkinLayoutOverrides("community.illusia-voice").pages.home?.mobile?.["home.header"]?.order, 2);
clearSkinLayoutOverrides("community.illusia-voice");
assert.deepEqual(loadSkinLayoutOverrides("community.illusia-voice"), { schemaVersion: 1, pages: {} });
assert.equal(JSON.parse(storage.getItem(SKIN_LAYOUT_STORAGE_KEY) ?? "null").schemaVersion, 2);