mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-22 17:27:17 +00:00
Compare commits
3 Commits
add-automa
...
default-ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d39901c88 | ||
|
|
9f4650b012 | ||
|
|
1fe8b36d6e |
@@ -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";
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ export class HatGraphNode extends LitElement {
|
|||||||
|
|
||||||
@property({ reflect: true, type: Boolean }) graphstart?: boolean;
|
@property({ reflect: true, type: Boolean }) graphstart?: boolean;
|
||||||
|
|
||||||
|
@property({ reflect: true, type: Boolean }) spacer?: boolean;
|
||||||
|
|
||||||
@property({ reflect: true, type: Boolean }) nofocus?: boolean;
|
@property({ reflect: true, type: Boolean }) nofocus?: boolean;
|
||||||
|
|
||||||
@property({ reflect: true, type: Number }) badge?: number;
|
@property({ reflect: true, type: Number }) badge?: number;
|
||||||
@@ -22,7 +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;
|
return;
|
||||||
}
|
}
|
||||||
const bbox = svgEl.getBBox();
|
const bbox = svgEl.getBBox();
|
||||||
@@ -42,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
|
||||||
@@ -50,7 +62,9 @@ export class HatGraphNode extends LitElement {
|
|||||||
<path
|
<path
|
||||||
class="connector"
|
class="connector"
|
||||||
d="
|
d="
|
||||||
M 0 ${-SPACING - NODE_SIZE / 2}
|
M 0 ${
|
||||||
|
this.spacer ? SPACING + NODE_SIZE + 1 : -SPACING - NODE_SIZE / 2
|
||||||
|
}
|
||||||
L 0 0
|
L 0 0
|
||||||
"
|
"
|
||||||
line-caps="round"
|
line-caps="round"
|
||||||
@@ -58,11 +72,15 @@ export class HatGraphNode extends LitElement {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
<g class="node">
|
<g class="node">
|
||||||
<circle
|
${
|
||||||
|
!this.spacer
|
||||||
|
? svg`<circle
|
||||||
cx="0"
|
cx="0"
|
||||||
cy="0"
|
cy="0"
|
||||||
r="${NODE_SIZE / 2}"
|
r="${NODE_SIZE / 2}"
|
||||||
/>
|
/>`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
${
|
${
|
||||||
this.badge
|
this.badge
|
||||||
? svg`
|
? svg`
|
||||||
|
|||||||
@@ -192,6 +192,14 @@ class HatScriptGraph extends LitElement {
|
|||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
<hat-graph>
|
<hat-graph>
|
||||||
|
<hat-graph-node
|
||||||
|
nofocus
|
||||||
|
spacer
|
||||||
|
class=${classMap({
|
||||||
|
track:
|
||||||
|
trace !== undefined && trace[0].result?.choice === "default",
|
||||||
|
})}
|
||||||
|
></hat-graph-node>
|
||||||
${ensureArray(config.default)?.map((action, i) =>
|
${ensureArray(config.default)?.map((action, i) =>
|
||||||
this.render_node(action, `${path}/default/${i}`)
|
this.render_node(action, `${path}/default/${i}`)
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user