diff --git a/buildoz.css b/buildoz.css index 6986a8d..fa4f854 100644 --- a/buildoz.css +++ b/buildoz.css @@ -375,7 +375,8 @@ bz-grafloweditor .inner-console section .cols-2 input{ bz-gantt{ position: relative; - --row: 30px; + --row: 25px; + --bar-gap: 4px; /* space above & below each bar inside its row */ } bz-gantt ul.tasks{ list-style: none; @@ -393,6 +394,6 @@ bz-gantt ul.tasks li{ bz-gantt.gantt bz-graflow{ position: absolute; - left: 8em; - top: 0.5em; + left: calc(var(--tasks-width, 7em) + 1em); + top: var(--bar-gap); } \ No newline at end of file diff --git a/bzGantt.js b/bzGantt.js index 0908b4b..f873e97 100644 --- a/bzGantt.js +++ b/bzGantt.js @@ -20,6 +20,7 @@ class BZgantt extends Buildoz { async connectedCallback(){ await customElements.whenDefined('bz-graflow') super.connectedCallback() + this.rowHeight = parseFloat(getComputedStyle(this).getPropertyValue('--row')) || 30 this.ul = document.createElement('ul') this.ul.classList.add('tasks') @@ -160,7 +161,7 @@ class BZgantt extends Buildoz { for(const dep of task.dependsOn ?? []){ flow.links.push({ "from": [dep, "out1"], "to": [task.id, "inp1"] }) } - curY += 30 // row height + curY += this.rowHeight } return flow } @@ -172,6 +173,16 @@ class BZgantt extends Buildoz { li.textContent = task.name this.ul.appendChild(li) } + + // Publish the widest label width, used by CSS to place the graflow + const range = document.createRange() + let maxWidth = 0 + for(const li of this.ul.children){ + range.selectNodeContents(li) + maxWidth = Math.max(maxWidth, range.getBoundingClientRect().width) + } + this.style.setProperty('--tasks-width', Math.ceil(maxWidth) + 'px') + const flow = this.buildFlow() this.graflow.loadFlow({ "nodesFile": this.nodesfile, diff --git a/graflow_examples/nodesLib/nodesGantt.html b/graflow_examples/nodesLib/nodesGantt.html index 4ef9b54..4344417 100644 --- a/graflow_examples/nodesLib/nodesGantt.html +++ b/graflow_examples/nodesLib/nodesGantt.html @@ -9,7 +9,8 @@ .bzgf-node .body{ border-radius: 4px; overflow: hidden; - height: 1.2em; + height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px)); + line-height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px)); text-overflow: ellipsis; white-space: nowrap; font-size: .9em; diff --git a/graflow_examples/test8.html b/graflow_examples/test8.html index ebf57f6..2216b9e 100644 --- a/graflow_examples/test8.html +++ b/graflow_examples/test8.html @@ -29,16 +29,16 @@