mapcomplete/customGenerator.ts

66 lines
2.4 KiB
TypeScript
Raw Normal View History

import {UIEventSource} from "./Logic/UIEventSource";
import SingleSetting from "./UI/CustomGenerator/SingleSetting";
import Combine from "./UI/Base/Combine";
import {VariableUiElement} from "./UI/Base/VariableUIElement";
import GeneralSettings from "./UI/CustomGenerator/GeneralSettings";
import {TabbedComponent} from "./UI/Base/TabbedComponent";
import AllLayersPanel from "./UI/CustomGenerator/AllLayersPanel";
import SharePanel from "./UI/CustomGenerator/SharePanel";
2020-09-02 11:37:34 +02:00
import {GenerateEmpty} from "./UI/CustomGenerator/GenerateEmpty";
import PageSplit from "./UI/Base/PageSplit";
import HelpText from "./Customizations/HelpText";
import {TagRendering} from "./Customizations/TagRendering";
2020-09-02 11:37:34 +02:00
const es = new UIEventSource(GenerateEmpty.createTestLayout());
const encoded = es.map(config => btoa(JSON.stringify(config)));
const liveUrl = encoded.map(encoded => `./index.html?userlayout=${es.data.id}#${encoded}`)
2020-08-31 13:25:13 +02:00
const iframe = liveUrl.map(url => `<iframe src='${url}' width='100%' height='99%' style="box-sizing: border-box" title='Theme Preview'></iframe>`);
2020-09-02 11:37:34 +02:00
TagRendering.injectFunction();
const currentSetting = new UIEventSource<SingleSetting<any>>(undefined)
const generalSettings = new GeneralSettings(es, currentSetting);
const languages = generalSettings.languages;
2020-09-02 11:37:34 +02:00
// The preview
const preview = new Combine([
new VariableUiElement(iframe.stabilized(2500))
]).SetClass("preview")
new TabbedComponent([
{
header: "<img src='./assets/gear.svg'>",
2020-09-02 11:37:34 +02:00
content:
new PageSplit(
generalSettings.SetStyle("width: 50vw;"),
new Combine([
new HelpText(currentSetting).SetStyle("height:calc(100% - 65vh); width: 100%; display:block; overflow-y: auto"),
preview.SetStyle("height:65vh; width:100%; display:block")
]).SetStyle("position:relative; width: 50%;")
)
},
{
header: "<img src='./assets/layers.svg'>",
2020-09-02 11:37:34 +02:00
content: new AllLayersPanel(es, languages)
},
{
header: "<img src='./assets/floppy.svg'>",
2020-08-31 13:25:13 +02:00
content: new VariableUiElement(es.map(config => {
return JSON.stringify(config, null, 2)
.replace(/\n/g, "<br/>")
.replace(/ /g, "&nbsp;");
}))
},
{
header: "<img src='./assets/share.svg'>",
content: new SharePanel(es, liveUrl)
}
2020-09-02 11:37:34 +02:00
], 1).SetClass("main-tabs")
.AttachTo("maindiv");
2020-08-08 21:17:17 +02:00