mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17:47 +00:00
Update hat-graph-node.ts
This commit is contained in:
parent
9f4650b012
commit
8d39901c88
@ -1,4 +1,5 @@
|
|||||||
import { css, customElement, LitElement, property, svg } from "lit-element";
|
import { css, customElement, LitElement, property, svg } from "lit-element";
|
||||||
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
|
|
||||||
import { NODE_SIZE, SPACING } from "./hat-graph";
|
import { NODE_SIZE, SPACING } from "./hat-graph";
|
||||||
|
|
||||||
@ -24,13 +25,7 @@ export class HatGraphNode extends LitElement {
|
|||||||
|
|
||||||
updated() {
|
updated() {
|
||||||
const svgEl = this.shadowRoot?.querySelector("svg");
|
const svgEl = this.shadowRoot?.querySelector("svg");
|
||||||
if (!svgEl) {
|
if (!svgEl || this.spacer) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.spacer) {
|
|
||||||
svgEl.setAttribute("width", "10px");
|
|
||||||
svgEl.setAttribute("height", `${SPACING + NODE_SIZE + 1}px`);
|
|
||||||
svgEl.setAttribute("viewBox", `-5 0 10 ${SPACING + NODE_SIZE + 1}`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const bbox = svgEl.getBBox();
|
const bbox = svgEl.getBBox();
|
||||||
@ -50,6 +45,15 @@ export class HatGraphNode extends LitElement {
|
|||||||
render() {
|
render() {
|
||||||
return svg`
|
return svg`
|
||||||
<svg
|
<svg
|
||||||
|
width=${ifDefined(this.spacer ? `${SPACING}px` : undefined)}
|
||||||
|
height=${ifDefined(
|
||||||
|
this.spacer ? `${SPACING + NODE_SIZE + 1}px` : undefined
|
||||||
|
)}
|
||||||
|
viewBox=${ifDefined(
|
||||||
|
this.spacer
|
||||||
|
? `-${SPACING / 2} 0 10 ${SPACING + NODE_SIZE + 1}`
|
||||||
|
: undefined
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
${
|
${
|
||||||
this.graphstart
|
this.graphstart
|
||||||
|
Loading…
x
Reference in New Issue
Block a user