[HOME] Панель: план подложкой (img) + слой зон SVG, контуры комнат уточнены
lint / hygiene (push) Failing after 29s

This commit is contained in:
root committed 2026-11-01 22:34:50 +03:00
1 parent 9128b435b4
commit 5709f5b837
2 files changed
+20 -15

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 KiB

After

Width:  |  Height:  |  Size: 368 KiB

+20 -15
View File
@@ -1,21 +1,23 @@
/* Покомнатная панель: план владельца + зоны-полигоны по контурам комнат. */
/* Покомнатная панель: план-подложка (img) + слой зон (SVG) по контурам комнат. */
const ROOMS = [
{ id: "terrasa", name: "Терраса", icon: "mdi:deck",
poly: [[0, 0], [2.45, 0], [2.45, 8.35], [0, 8.35]] },
poly: [[0.00, 0.00], [2.45, 0.00], [2.45, 8.35], [0.00, 8.35]] },
{ id: "kitchen", name: "Кухня-гостиная", icon: "mdi:silverware-fork-knife",
poly: [[2.45, 0], [6.16, 0], [6.16, 8.35], [2.45, 8.35]] },
poly: [[2.45, 0.00], [6.16, 0.00], [6.16, 8.35], [2.45, 8.35]] },
{ id: "postirochnaia", name: "Тех.пом.", icon: "mdi:server",
poly: [[5.71, -1.5], [7.62, -1.5], [7.62, 0], [5.71, 0]] },
poly: [[5.71, -1.50], [7.62, -1.50], [7.62, 0.00], [5.71, 0.00]] },
{ id: "sanuzel", name: "Санузел", icon: "mdi:shower",
poly: [[5.83, 0.30], [7.74, 0.30], [7.74, 3.07], [5.83, 3.07]] },
poly: [[5.83, 0.30], [7.74, 0.30], [7.74, 1.55], [7.30, 1.55],
[7.30, 3.07], [5.83, 3.07]] },
{ id: "tualet", name: "Туалет", icon: "mdi:toilet",
poly: [[8.69, 2.71], [9.40, 2.71], [9.40, 3.55], [8.69, 3.55]] },
poly: [[7.74, 1.90], [8.62, 1.90], [8.62, 3.55], [7.74, 3.55]] },
{ id: "garderob", name: "Гардероб", icon: "mdi:hanger",
poly: [[9.05, 0.05], [10.95, 0.05], [10.95, 1.50], [9.05, 1.50]] },
{ id: "kladovaia", name: "Кладовая", icon: "mdi:package-variant",
poly: [[9.29, 1.50], [10.95, 1.50], [10.95, 2.83], [9.29, 2.83]] },
{ id: "koridor", name: "Холл", icon: "mdi:door-open",
poly: [[7.74, 3.07], [11.07, 3.07], [11.07, 5.48], [7.74, 5.48]] },
poly: [[7.74, 3.07], [9.05, 3.07], [9.05, 2.83], [11.07, 2.83],
[11.07, 5.48], [7.74, 5.48]] },
{ id: "prihozhaya", name: "Прихожая", icon: "mdi:door",
poly: [[5.95, 5.48], [7.74, 5.48], [7.74, 7.41], [5.95, 7.41]] },
{ id: "tambur", name: "Тамбур", icon: "mdi:door",
@@ -101,16 +103,17 @@ class RoomsCard extends HTMLElement {
if (d === "light" || d === "switch") this._hass.callService(d, "toggle", { entity_id: e });
}
_planSvg(areaId) {
_planHtml(areaId) {
const pts = (poly) => poly.map(([x, y]) =>
`${(x * PX_M + PX0).toFixed(1)},${(y * PY_M + PY0).toFixed(1)}`).join(" ");
const shapes = ROOMS.map((r) => {
const sel = r.id === areaId;
return `<polygon class="zone ${sel ? "sel" : ""}" data-a="${r.id}" points="${pts(r.poly)}" />`;
return `<polygon class="zone ${sel ? "sel" : ""}" data-a="${r.id}" points="${pts(r.poly)}"><title>${r.name}</title></polygon>`;
}).join("");
return `<svg class="plan" viewBox="0 0 ${IMG_W} ${IMG_H}" preserveAspectRatio="xMidYMid meet">
<image href="/local/house3d/plan.png" x="0" y="0" width="${IMG_W}" height="${IMG_H}"/>
${shapes}</svg>`;
return `<div class="plan-wrap">
<img class="plan-img" src="/local/house3d/plan.png?v=6" alt="План дома"/>
<svg class="plan-layer" viewBox="0 0 ${IMG_W} ${IMG_H}" preserveAspectRatio="none">${shapes}</svg>
</div>`;
}
_render() {
@@ -158,9 +161,11 @@ class RoomsCard extends HTMLElement {
.bar button { background:rgba(30,36,44,.9); color:#cfe0f0; border:1px solid #39424e;
border-radius:9px; padding:4px 10px; font-size:12px; cursor:pointer; }
.bar button.on { border-color:#4aa3ff; color:#dceaff; background:rgba(74,163,255,.16); }
.plan { display:block; width:100%; height:auto; border-radius:12px; background:#f7f7f4; }
.plan-wrap { position:relative; line-height:0; border-radius:12px; overflow:hidden; background:#f7f7f4; }
.plan-img { display:block; width:100%; height:auto; }
.plan-layer { position:absolute; inset:0; width:100%; height:100%; }
.zone { fill:rgba(47,127,224,0); stroke:rgba(47,127,224,0); stroke-width:2; cursor:pointer; transition:.12s; }
.zone:hover { fill:rgba(47,127,224,.18); stroke:rgba(47,127,224,.85); }
.zone:hover { fill:rgba(47,127,224,.18); stroke:rgba(47,127,224,.9); }
.zone.sel { fill:rgba(47,127,224,.30); stroke:rgba(20,90,200,1); stroke-width:3; }
.grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap:10px; }
.tile { text-align:left; border:1px solid #2a2f36; border-radius:14px;
@@ -188,7 +193,7 @@ class RoomsCard extends HTMLElement {
<button class="${this._mode === "plan" ? "on" : ""}" data-mode="plan">План</button>
<button class="${this._mode === "tiles" ? "on" : ""}" data-mode="tiles">Плитки</button>
</div>
${this._mode === "plan" ? this._planSvg(areaId) : `<div class="grid">${tiles}</div>`}
${this._mode === "plan" ? this._planHtml(areaId) : `<div class="grid">${tiles}</div>`}
${detail}`;
this.shadowRoot.querySelectorAll("[data-mode]").forEach((b) =>