Skip to content

Commit 6a6d2b7

Browse files
Retain status background color when selected
The border now turns a thicker black to indicate it is selected while keeping the selected color. Also add a box around the status name to indicate the clickable area, center the status name, and use a default cursor rather than the text I-beam since you can't edit the text directly.
1 parent 8273f99 commit 6a6d2b7

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

share/static/css/elevator/lifecycleui.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ path.link {
55
cursor: pointer;
66
}
77

8-
g text {
9-
cursor: text;
10-
}
118

129
g circle.node-selected {
13-
fill: #98b9eb !important;
10+
stroke-width: 3px !important;
1411
}
1512

1613
.dragline {

share/static/js/lifecycleui-editor.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ RT.NewLifecycleEditor ||= class {
641641
.attr("class", "node");
642642

643643
nodeEnter.append("circle");
644+
nodeEnter.append("rect").attr("class", "label-bg");
644645
nodeEnter.append("text");
645646
nodeEnter.append("title");
646647

@@ -713,7 +714,9 @@ RT.NewLifecycleEditor ||= class {
713714
return -textLength/2;
714715
})
715716
.attr("y", 0)
717+
.attr("dominant-baseline", "central")
716718
.style("font-size", "10px")
719+
.style("cursor", "default")
717720
.attr("fill", function(d) {
718721
var bg = d.color;
719722
if ( !bg ) {
@@ -731,6 +734,35 @@ RT.NewLifecycleEditor ||= class {
731734
self.UpdateNode(d);
732735
});
733736

737+
self.node.select("rect.label-bg")
738+
.each(function(d) {
739+
var textEl = d3.select(this.parentNode).select("text").node();
740+
var bbox = textEl.getBBox();
741+
var padding = 3;
742+
var bg = d.color;
743+
if ( !bg ) {
744+
switch(d.type) {
745+
case 'active': bg = '#547CCC'; break;
746+
case 'inactive': bg = '#4bb2cc'; break;
747+
case 'initial': bg = '#599ACC'; break;
748+
}
749+
}
750+
d3.select(this)
751+
.attr("x", bbox.x - padding)
752+
.attr("y", bbox.y - padding)
753+
.attr("width", bbox.width + padding * 2)
754+
.attr("height", bbox.height + padding * 2)
755+
.attr("rx", 2)
756+
.attr("fill", "none")
757+
.attr("stroke", contrastTextColor(bg))
758+
.attr("stroke-width", 1);
759+
})
760+
.on("click", function(d) {
761+
d3.event.stopPropagation();
762+
d3.event.preventDefault();
763+
self.UpdateNode(d);
764+
});
765+
734766
self.node.select("title")
735767
.text(function(d) { return d.type; });
736768
}

0 commit comments

Comments
 (0)