Improved mod-card. Added report_size option, fix #17
This commit is contained in:
parent
35d61368cc
commit
028a1d1986
13
README.md
13
README.md
@ -246,6 +246,19 @@ card:
|
||||
```
|
||||

|
||||
|
||||
> Note: mod-card sets it's own `background` to `transparent`. That means, `--ha-card-background` will have no effect on mod-card itself. Instead, you ahve to modify the `background` property directly.
|
||||
|
||||
Mod-card also allows you to manually specify a `cardHeight` of a card. This can be used to slightly modify the behavior of the layout engine of lovelace. See [this description](https://github.com/thomasloven/lovelace-layout-card#auto-layout) for details.
|
||||
The cardHeight is set with the `report_size:` option:
|
||||
|
||||
```yaml
|
||||
type: custom:mod-card
|
||||
report_size: 5
|
||||
card:
|
||||
... etc ...
|
||||
```
|
||||
|
||||
|
||||
# FAQ
|
||||
|
||||
### How do I convert my old card-modder configuration to card-mod?
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
||||
import { LitElement, html, css} from "card-tools/src/lit-element";
|
||||
import "card-tools/src/card-maker";
|
||||
import { LitElement, html} from "card-tools/src/lit-element";
|
||||
import { createCard } from "card-tools/src/lovelace-element";
|
||||
import { hass } from "card-tools/src/hass";
|
||||
|
||||
const NO_STYLE = `
|
||||
ha-card {
|
||||
@ -26,18 +27,33 @@ class ModCard extends LitElement {
|
||||
this._config.style["."] = NO_STYLE;
|
||||
}
|
||||
|
||||
this.card = createCard(this._config.card);
|
||||
this.card.hass = hass();
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<ha-card modcard>
|
||||
<card-maker
|
||||
.config=${this._config.card}
|
||||
.hass=${this.hass}
|
||||
></card-maker>
|
||||
${this.card}
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
|
||||
set hass(hass) {
|
||||
if(!this.card) return;
|
||||
this.card.hass = hass;
|
||||
}
|
||||
|
||||
getCardSize() {
|
||||
if(this._config.report_size)
|
||||
return this._config.report_size;
|
||||
let ret = this.shadowRoot;
|
||||
if(ret) ret = ret.querySelector("ha-card card-maker");
|
||||
if(ret) ret = ret.getCardSize;
|
||||
if(ret) ret = ret();
|
||||
if(ret) return ret;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("mod-card", ModCard);
|
Loading…
x
Reference in New Issue
Block a user