import { LitElement, property, html, customElement, TemplateResult } from 'lit-element';
import { WccDefaultElement } from './wcc-defaultelement';
// wcc tools
import './wcc-frame';
import './wcc-sidebar';
import './wcc-properties';
@customElement('wcc-dashboard')
export class WccDashboard extends LitElement {
@property()
public selectedItem: TemplateResult | LitElement = WccDefaultElement as any;
@property()
public selectedInstance;
@property()
public selectedViewport: string = 'desktop';
@property()
public pages: { [key: string]: TemplateResult } = {};
@property()
public elements: { [key: string]: LitElement } = {};
constructor(elementsArg?: { [key: string]: LitElement }, pagesArg?: { [key: string]: TemplateResult }) {
super();
if (elementsArg) {
this.elements = elementsArg;
}
if (pagesArg) {
this.pages = pagesArg;
}
}
public render(): TemplateResult {
return html`
{
this.selectedItem = eventArg.detail;
}}>
{this.selectedViewport = eventArg.detail; this.updateSlot();}}>
${(() => {
if (this.selectedItem instanceof TemplateResult) {
return this.selectedItem;
} else if (this.selectedItem) {
console.log(this.selectedItem);
const anonItem: any = this.selectedItem;
if (anonItem.demo) {
return html`${anonItem.demo}`;
} else {
alert(`component does not expose a demo property.`);
}
} else {
}
})()}
${this.selectedViewport}
`;
}
public updateSlot() {
console.log('updateSlot');
const oldSelectedItem = this.selectedItem;
this.selectedItem = null;
setTimeout(() => {
this.selectedItem = oldSelectedItem;
}, 0);
}
}