import { LitElement, property, html, customElement, TemplateResult } from 'lit-element'; export type TEnvironment = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone'; let environment: TEnvironment = 'native'; export const setEnvironment = envArg => { environment = envArg; }; @customElement('wcc-properties') export class WccProperties extends LitElement { @property() public selectedItem: TemplateResult | LitElement; @property() public selectedInstance; @property() public selectedViewport = 'native'; @property() public warning: string = null; public render(): TemplateResult { return html`
Properties
${(() => { if (this.selectedItem && !(this.selectedItem instanceof TemplateResult)) { const anonItem: any = this.selectedItem; const classProperties: Map = anonItem._classProperties; const returnArray: TemplateResult[] = []; for (const key of classProperties.keys()) { returnArray.push( html`
${key} / ${classProperties.get(key).type.name} /
${(() => {
                          const result = this.selectedInstance
                            ? JSON.stringify(this.selectedInstance[key], null, 2)
                            : null;
                          return result;
                        })()}
` ); } return returnArray; } })()}
Viewports
{ this.selectViewport('phone'); }} > Phone
smartphone
{ this.selectViewport('phablet'); }} > Phablet
smartphone
{ this.selectViewport('tablet'); }} > Tablet
tablet
{ this.selectViewport('native'); }} > Desktop
desktop_windows
Docs
${this.warning ? html`
${this.warning}
` : null} `; } public selectViewport(viewport: TEnvironment) { this.selectedViewport = viewport; setEnvironment(viewport); this.dispatchEvent( new CustomEvent('selectedViewport', { detail: viewport }) ); } }