Mercurial > code > home > repos > light9
changeset 2411:66a4db80ce6e
keep 44fc
author | drewp@bigasterisk.com |
---|---|
date | Sat, 18 May 2024 23:22:00 -0700 |
parents | 44fc477970bf (current diff) 6697a68800d2 (diff) |
children | 560c9eab6647 |
files | web/TiledHome.ts |
diffstat | 1 files changed, 79 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/tiledLayoutPersistence.ts Sat May 18 23:22:00 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", + // }, + // ], + // }, + // ], + // }, + ], +};