mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Update Aspect Ratio on Map card (#2126)
* Update Aspect Ratio * Update Card Size
This commit is contained in:
parent
4487c3dc1a
commit
ffc7f9706d
@ -10,6 +10,7 @@ import processConfigEntities from "../common/process-config-entities";
|
||||
import computeStateDomain from "../../../common/entity/compute_state_domain";
|
||||
import computeStateName from "../../../common/entity/compute_state_name";
|
||||
import debounce from "../../../common/util/debounce";
|
||||
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
||||
|
||||
Leaflet.Icon.Default.imagePath = "/static/images/leaflet";
|
||||
|
||||
@ -97,7 +98,15 @@ class HuiMapCard extends PolymerElement {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$.root.style.paddingTop = this._config.aspect_ratio || "100%";
|
||||
const ratio = parseAspectRatio(this._config.aspect_ratio);
|
||||
|
||||
if (ratio && ratio.w > 0 && ratio.h > 0) {
|
||||
this.$.root.style.paddingBottom = `${((100 * ratio.h) / ratio.w).toFixed(
|
||||
2
|
||||
)}%`;
|
||||
} else {
|
||||
this.$.root.style.paddingBottom = "100%";
|
||||
}
|
||||
}
|
||||
|
||||
setConfig(config) {
|
||||
@ -110,8 +119,13 @@ class HuiMapCard extends PolymerElement {
|
||||
}
|
||||
|
||||
getCardSize() {
|
||||
let ar = this._config.aspect_ratio || "100%";
|
||||
ar = ar.substr(0, ar.length - 1);
|
||||
const ratio = parseAspectRatio(this._config.aspect_ratio);
|
||||
let ar;
|
||||
if (ratio && ratio.w > 0 && ratio.h > 0) {
|
||||
ar = `${((100 * ratio.h) / ratio.w).toFixed(2)}`;
|
||||
} else {
|
||||
ar = "100";
|
||||
}
|
||||
return 1 + Math.floor(ar / 25) || 3;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user