UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

65 lines 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContentHeaderPart = void 0; const __1 = require(".."); const section_1 = require("./section"); const selective_edit_1 = require("@blinkk/selective-edit"); const template_1 = require("../../template"); class ContentHeaderPart extends __1.BasePart { constructor(config) { super(); this.config = config; } classesForPart() { return { le__part__content__header: true, }; } handleSectionClick(evt, section) { for (const sectionPart of this.config.sections) { sectionPart.isVisible = false; } this.config.storage.setItem(section_1.STORAGE_CONTENT_SECTION, section.section); section.isVisible = true; this.render(); } template(editor) { let currentSection = undefined; for (const sectionPart of this.config.sections) { if (sectionPart.isVisible) { currentSection = sectionPart; break; } } return selective_edit_1.html `<div class=${selective_edit_1.classMap(this.classesForPart())}> <div class="le__part__content__header__sections"> ${selective_edit_1.repeat(this.config.sections, section => section.section, section => selective_edit_1.html `<div class=${selective_edit_1.classMap({ le__part__content__header__section: true, le__clickable: section.isVisible || currentSection?.canChangeSection || false, 'le__part__content__header__section--selected': section.isVisible || false, 'le__part__content__header__section--disabled': !section.isVisible && !currentSection?.canChangeSection, })} @click=${(evt) => { // Block switching sections when if (!currentSection?.canChangeSection) { return; } this.handleSectionClick(evt, section); }} > ${section.label} </div>`)} </div> <div class="le__part__content__header__actions"> ${currentSection?.isProcessing ? selective_edit_1.html `${template_1.templateLoading(editor)}` : ''} ${currentSection?.templateStatus(editor) || selective_edit_1.html ``} ${currentSection?.templateAction(editor) || selective_edit_1.html ``} </div> </div>`; } } exports.ContentHeaderPart = ContentHeaderPart; //# sourceMappingURL=header.js.map