Skip to content

Commit

Permalink
v0.8.0 Release Candidate
Browse files Browse the repository at this point in the history
* Improved ability to format the card using card-mod
* Major refactor of all code

NOTE:  If you notice problems with this latest release, please report the issue on the repo and revert back to the prior version.
  • Loading branch information
vasqued2 authored May 27, 2023
1 parent 049909d commit 75b0bea
Show file tree
Hide file tree
Showing 12 changed files with 1,170 additions and 917 deletions.
55 changes: 55 additions & 0 deletions dist/card_editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Define and register the UI Card Editor
//
import { html, LitElement } from "https://cdn.jsdelivr.net/gh/lit/dist@2/core/lit-core.min.js";


export class MyCustomCardEditor extends LitElement {

static get properties() {
return {
hass: {},
_config: {},
};
}

// setConfig works the same way as for the card itself
setConfig(config) {
this._config = config;
}

// This function is called when the input element of the editor loses focus
entityChanged(ev) {

// We make a copy of the current config so we don't accidentally overwrite anything too early
const _config = Object.assign({}, this._config);
// Then we update the entity value with what we just got from the input field
_config.entity = ev.target.value;
// And finally write back the updated configuration all at once
this._config = _config;

// A config-changed event will tell lovelace we have made changed to the configuration
// this make sure the changes are saved correctly later and will update the preview
const event = new CustomEvent("config-changed", {
detail: { config: _config },
bubbles: true,
composed: true,
});
this.dispatchEvent(event);
}

render() {
if (!this.hass || !this._config) {
return html``;
}

// @focusout below will call entityChanged when the input field loses focus (e.g. the user tabs away or clicks outside of it)
return html`
Entity:
<input
.value=${this._config.entity}
@focusout=${this.entityChanged}
></input>
`;
}
}
1 change: 1 addition & 0 deletions dist/const.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export let VERSION = "v0.8.0"
Loading

0 comments on commit 75b0bea

Please sign in to comment.