import {UIElement} from "../UIElement"; import {TabbedComponent} from "../Base/TabbedComponent"; import {SubtleButton} from "../Base/SubtleButton"; import {UIEventSource} from "../../Logic/UIEventSource"; import {LayoutConfigJson} from "../../Customizations/JSON/LayoutConfigJson"; import Combine from "../Base/Combine"; import {GenerateEmpty} from "./GenerateEmpty"; import LayerPanelWithPreview from "./LayerPanelWithPreview"; export default class AllLayersPanel extends UIElement { private panel: UIElement; private readonly _config: UIEventSource; private readonly languages: UIEventSource; constructor(config: UIEventSource, languages: UIEventSource) { super(undefined); this._config = config; this.languages = languages; this.createPanels(); const self = this; config.map(config => config.layers.length).addCallback(() => self.createPanels()); } private createPanels() { const self = this; const tabs = []; const layers = this._config.data.layers; for (let i = 0; i < layers.length; i++) { tabs.push({ header: "", content: new LayerPanelWithPreview(this._config, this.languages, i)}); } tabs.push({ header: "", content: new Combine([ "

Layer editor

", "In this tab page, you can add and edit the layers of the theme. Click the layers above or add a new layer to get started.", new SubtleButton( "./assets/layersAdd.svg", "Add a new layer" ).onClick(() => { self._config.data.layers.push(GenerateEmpty.createEmptyLayer()) self._config.ping(); })]) }) this.panel = new TabbedComponent(tabs, new UIEventSource(Math.max(0, layers.length - 1))); this.Update(); } InnerRender(): string { return this.panel.Render(); } }