added editor config
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
+53
-54
@@ -1,23 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
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
|
||||
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
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
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);
|
||||
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;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
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
|
||||
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
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2302,33 +2302,32 @@ LitElement.finalized = true;
|
||||
*/
|
||||
LitElement.render = render$1;
|
||||
|
||||
// TODO Name your custom element
|
||||
let BoilerplateCard = class BoilerplateCard extends LitElement {
|
||||
setConfig(config) {
|
||||
// TODO Check for required fields and that they are of the proper format
|
||||
if (!config || config.show_error) {
|
||||
throw new Error('Invalid configuration');
|
||||
}
|
||||
this._config = config;
|
||||
}
|
||||
render() {
|
||||
if (!this._config || !this.hass) {
|
||||
return html ``;
|
||||
}
|
||||
// TODO Check for stateObj or other necessary things and render a warning if missing
|
||||
if (this._config.show_warning) {
|
||||
// TODO Name your custom element
|
||||
let BoilerplateCard = class BoilerplateCard extends LitElement {
|
||||
setConfig(config) {
|
||||
// TODO Check for required fields and that they are of the proper format
|
||||
if (!config || config.show_error) {
|
||||
throw new Error('Invalid configuration');
|
||||
}
|
||||
this._config = config;
|
||||
}
|
||||
render() {
|
||||
if (!this._config || !this.hass) {
|
||||
return html ``;
|
||||
}
|
||||
// TODO Check for stateObj or other necessary things and render a warning if missing
|
||||
if (this._config.show_warning) {
|
||||
return html `
|
||||
<ha-card>
|
||||
<div class="warning">Show Warning</div>
|
||||
</ha-card>`;
|
||||
}
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
return html `
|
||||
<ha-card
|
||||
.header=${this._config.name ? this._config.name : 'Boilerplate'}
|
||||
></ha-card>
|
||||
`;
|
||||
}
|
||||
static get styles() {
|
||||
<ha-card .header=${this._config.name ? this._config.name : 'Boilerplate'}></ha-card>
|
||||
`;
|
||||
}
|
||||
static get styles() {
|
||||
return css `
|
||||
.warning {
|
||||
display: block;
|
||||
@@ -2336,15 +2335,15 @@ let BoilerplateCard = class BoilerplateCard extends LitElement {
|
||||
background-color: #fce588;
|
||||
padding: 8px;
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
property()
|
||||
], BoilerplateCard.prototype, "hass", void 0);
|
||||
__decorate([
|
||||
property()
|
||||
], BoilerplateCard.prototype, "_config", void 0);
|
||||
BoilerplateCard = __decorate([
|
||||
customElement('boilerplate-card')
|
||||
`;
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
property()
|
||||
], BoilerplateCard.prototype, "hass", void 0);
|
||||
__decorate([
|
||||
property()
|
||||
], BoilerplateCard.prototype, "_config", void 0);
|
||||
BoilerplateCard = __decorate([
|
||||
customElement('boilerplate-card')
|
||||
], BoilerplateCard);
|
||||
|
||||
+23
-10
@@ -1,14 +1,27 @@
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
file: 'boilerplate-card.js',
|
||||
format: 'es'
|
||||
|
||||
const commonPlugins = [
|
||||
resolve(),
|
||||
typescript()
|
||||
];
|
||||
|
||||
export default [
|
||||
{
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
file: 'boilerplate-card.js',
|
||||
format: 'es'
|
||||
},
|
||||
plugins: [...commonPlugins]
|
||||
},
|
||||
plugins: [
|
||||
resolve(),
|
||||
typescript ()
|
||||
]
|
||||
};
|
||||
{
|
||||
input: 'src/editor.ts',
|
||||
output: {
|
||||
file: 'boilerplate-card-editor.js',
|
||||
format: 'es'
|
||||
},
|
||||
plugins: [...commonPlugins]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user