added editor config

This commit is contained in:
Leonardo Merza
2019-03-04 19:07:59 -05:00
parent dd9fe66805
commit a9d56f54a6
4 changed files with 77 additions and 64 deletions
+1
View File
@@ -0,0 +1 @@
+53 -54
View File
@@ -1,23 +1,23 @@
/*! ***************************************************************************** /*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved. Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0 License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT. MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License. and limitations under the License.
***************************************************************************** */ ***************************************************************************** */
function __decorate(decorators, target, key, desc) { function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r; return c > 3 && r && Object.defineProperty(target, key, r), r;
} }
/** /**
@@ -2302,33 +2302,32 @@ LitElement.finalized = true;
*/ */
LitElement.render = render$1; LitElement.render = render$1;
// TODO Name your custom element // TODO Name your custom element
let BoilerplateCard = class BoilerplateCard extends LitElement { let BoilerplateCard = class BoilerplateCard extends LitElement {
setConfig(config) { setConfig(config) {
// TODO Check for required fields and that they are of the proper format // TODO Check for required fields and that they are of the proper format
if (!config || config.show_error) { if (!config || config.show_error) {
throw new Error('Invalid configuration'); throw new Error('Invalid configuration');
} }
this._config = config; this._config = config;
} }
render() { render() {
if (!this._config || !this.hass) { if (!this._config || !this.hass) {
return html ``; return html ``;
} }
// TODO Check for stateObj or other necessary things and render a warning if missing // TODO Check for stateObj or other necessary things and render a warning if missing
if (this._config.show_warning) { if (this._config.show_warning) {
return html ` return html `
<ha-card> <ha-card>
<div class="warning">Show Warning</div> <div class="warning">Show Warning</div>
</ha-card>`; </ha-card>
} `;
}
return html ` return html `
<ha-card <ha-card .header=${this._config.name ? this._config.name : 'Boilerplate'}></ha-card>
.header=${this._config.name ? this._config.name : 'Boilerplate'} `;
></ha-card> }
`; static get styles() {
}
static get styles() {
return css ` return css `
.warning { .warning {
display: block; display: block;
@@ -2336,15 +2335,15 @@ let BoilerplateCard = class BoilerplateCard extends LitElement {
background-color: #fce588; background-color: #fce588;
padding: 8px; padding: 8px;
} }
`; `;
} }
}; };
__decorate([ __decorate([
property() property()
], BoilerplateCard.prototype, "hass", void 0); ], BoilerplateCard.prototype, "hass", void 0);
__decorate([ __decorate([
property() property()
], BoilerplateCard.prototype, "_config", void 0); ], BoilerplateCard.prototype, "_config", void 0);
BoilerplateCard = __decorate([ BoilerplateCard = __decorate([
customElement('boilerplate-card') customElement('boilerplate-card')
], BoilerplateCard); ], BoilerplateCard);
+23 -10
View File
@@ -1,14 +1,27 @@
import resolve from 'rollup-plugin-node-resolve'; import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2'; import typescript from 'rollup-plugin-typescript2';
export default {
input: 'src/index.ts', const commonPlugins = [
output: { resolve(),
file: 'boilerplate-card.js', typescript()
format: 'es' ];
export default [
{
input: 'src/index.ts',
output: {
file: 'boilerplate-card.js',
format: 'es'
},
plugins: [...commonPlugins]
}, },
plugins: [ {
resolve(), input: 'src/editor.ts',
typescript () output: {
] file: 'boilerplate-card-editor.js',
}; format: 'es'
},
plugins: [...commonPlugins]
}
]
View File