# HG changeset patch # User drewp@bigasterisk.com # Date 1715993306 25200 # Node ID 6697a68800d29cfc9ee29eb30983c48231a0c531 # Parent 9cbc93f80b055d2ea306e9ebd4d006e4c78e7f29# Parent 68d8e905d61ad7a3989986cb8b0f72799fa8bda2 junk merge just to avoid two heads diff -r 9cbc93f80b05 -r 6697a68800d2 web/TiledHome.ts --- a/web/TiledHome.ts Fri May 17 17:41:22 2024 -0700 +++ b/web/TiledHome.ts Fri May 17 17:48:26 2024 -0700 @@ -17,22 +17,7 @@ tabEnableRename: false, }, borders: [], - layout: { - type: "row", - weight: 100, - children: [ - { - type: "tabset", - weight: 50, - children: [{ type: "tab", name: "devsettings", component: "light9-device-settings" }], - }, - { - type: "tabset", - weight: 50, - children: [{ type: "tab", name: "collector", component: "light9-collector-ui" }], - }, - ], - }, + layout: fullLayout(persistedLayout) as FlexLayout.IJsonRowNode, }; // see https://github.com/lit/lit/tree/main/packages/labs/react diff -r 9cbc93f80b05 -r 6697a68800d2 web/tiledLayoutPersistence.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/tiledLayoutPersistence.ts Fri May 17 17:48:26 2024 -0700 @@ -0,0 +1,79 @@ +// for persistence +interface SimpleLayoutTab { + type: "tab"; + light9Element: string; +} +export interface SimpleLayout { + type: string; + weight?: number; + children: (SimpleLayout | SimpleLayoutTab)[]; +} +// for FlexLayout +interface FullLayoutTab { + type: "tab"; + name: string; + component: string; +} +interface FullLayout { + type: string; + weight?: number; + children: (FullLayout | FullLayoutTab)[]; +} +function tabConfigFromSimpleTabName(name: string): FullLayoutTab { + return { type: "tab", name: name.replace(/^light9-/, ""), component: name }; +} +export function simpleLayout(full: FullLayout | FullLayoutTab): SimpleLayout | SimpleLayoutTab { + if (full.type == "tab") { + return { type: "tab", light9Element: (full as FullLayoutTab).component }; + } else { + return { ...(full as FullLayout), children: (full as FullLayout).children.map(simpleLayout) }; + } +} +export function fullLayout(simple: SimpleLayout | SimpleLayoutTab): FullLayout | FullLayoutTab { + if (simple.type == "tab") { + return tabConfigFromSimpleTabName((simple as SimpleLayoutTab).light9Element); + } else { + return { ...(simple as SimpleLayout), children: (simple as SimpleLayout).children.map(fullLayout) }; + } +} +export const persistedLayout: SimpleLayout = { + type: "row", + children: [ + // { + // type: "tabset", + // weight: 50, + // children: [ + // { + // type: "tab", + // light9Element: "light9-device-settings", + // }, + // ], + // }, + // { + // type: "row", + // weight: 50, + // children: [ + // { + // type: "tabset", + // weight: 50, + // children: [ + // { + // type: "tab", + // light9Element: "light9-fade-ui", + // }, + // ], + // }, + // { + // type: "tabset", + // weight: 50, + // children: [ + // { + // type: "tab", + // light9Element: "light9-collector-ui", + // }, + // ], + // }, + // ], + // }, + ], +};