diff --git a/src/script-graph3.ts b/src/script-graph3.ts index 6fc2bdc..5a5bee8 100644 --- a/src/script-graph3.ts +++ b/src/script-graph3.ts @@ -36,7 +36,6 @@ const ICONS = { }; const SIZE = 24; -const DIST = 20; interface GraphNode extends LitElement{ render_svg(): TemplateResult; @@ -48,6 +47,12 @@ class ScriptGraphNode extends LitElement { @property() icon = "chevron-right"; + connectedCallback() { + super.connectedCallback(); + if(!this.hasAttribute('tabindex')) + this.setAttribute('tabindex', "0"); + } + get width() { return SIZE + 5; } @@ -56,7 +61,10 @@ class ScriptGraphNode extends LitElement { } render() { return svg` - + - ${xs.map((x) => { + ${branch_x.map((x) => { return svg` ` @@ -148,7 +168,7 @@ class ScriptGraphBranch extends LitElement { .icon=${"call-split"} > -
+
@@ -164,24 +184,28 @@ class ScriptGraphBranch extends LitElement { --stroke-clr: var(--stroke-color, rgb(3, 169, 244)); --hover-clr: var(--hover-color, rgb(255, 152, 0)); } - #head { - position: Absolute; - top: 5px; - left: 50%; - transform: translate(-50%, -50%); - } #branches { position: absolute; top: 20px; left: 0; display: flex; flex-direction: row; + align-items: center; } path.line { stroke: var(--stroke-clr); stroke-width: 2; fill: white; } + #head { + position: Absolute; + top: 5px; + left: 50%; + transform: translate(-50%, -50%); + } + :host(:focus-within) #head { + --stroke-color: green; + } `; } @@ -192,6 +216,7 @@ class ScriptGraph3 extends LitElement { @property() content = []; @property() _width = 0; @property() _height = 0; + @property() _distance = 20; async updateChildren() { return; @@ -205,9 +230,9 @@ class ScriptGraph3 extends LitElement { let h = 0; for(const c of this.children) { h += (c as any).height ?? 0; - h += 10; + h += this._distance; } - return h + 10; + return h + this._distance; } get width() { @@ -230,7 +255,7 @@ class ScriptGraph3 extends LitElement { " /> -
+
@@ -248,14 +273,14 @@ class ScriptGraph3 extends LitElement { } #nodes { position: absolute; - top: 10px; + top: var(--distance, 10px); left: 0; display: flex; flex-direction: column; align-items: center; } ::slotted(*) { - padding-bottom: 10px; + padding-bottom: var(--distance, 10px); } path.line { stroke: var(--stroke-clr);