1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Ensure node icon shade has properly rounded corners

This commit is contained in:
Nick O'Leary 2022-07-12 09:27:45 +01:00
parent c86e4f52a0
commit 6ff2232df3
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -4580,12 +4580,10 @@ RED.view = (function() {
icon_groupEl.setAttribute("y",0); icon_groupEl.setAttribute("y",0);
icon_groupEl.style["pointer-events"] = "none"; icon_groupEl.style["pointer-events"] = "none";
node[0][0].__iconGroup__ = icon_groupEl; node[0][0].__iconGroup__ = icon_groupEl;
var icon_shade = document.createElementNS("http://www.w3.org/2000/svg","rect"); var icon_shade = document.createElementNS("http://www.w3.org/2000/svg","path");
icon_shade.setAttribute("x",0); icon_shade.setAttribute("x",0);
icon_shade.setAttribute("y",0); icon_shade.setAttribute("y",0);
icon_shade.setAttribute("class","red-ui-flow-node-icon-shade") icon_shade.setAttribute("class","red-ui-flow-node-icon-shade")
icon_shade.setAttribute("width",30);
icon_shade.setAttribute("height",Math.min(50,d.h-4));
icon_groupEl.appendChild(icon_shade); icon_groupEl.appendChild(icon_shade);
node[0][0].__iconShade__ = icon_shade; node[0][0].__iconShade__ = icon_shade;
@ -4878,9 +4876,20 @@ RED.view = (function() {
} }
icon.attr("y",function(){return (d.h-d3.select(this).attr("height"))/2;}); icon.attr("y",function(){return (d.h-d3.select(this).attr("height"))/2;});
this.__iconShade__.setAttribute("height", d.h );
const iconShadeHeight = d.h
const iconShadeWidth = 30
this.__iconShade__.setAttribute("d", hideLabel ?
`M5 0 h${iconShadeWidth-10} a 5 5 0 0 1 5 5 v${iconShadeHeight-10} a 5 5 0 0 1 -5 5 h-${iconShadeWidth-10} a 5 5 0 0 1 -5 -5 v-${iconShadeHeight-10} a 5 5 0 0 1 5 -5` : (
"right" === d._def.align ?
`M 0 0 h${iconShadeWidth-5} a 5 5 0 0 1 5 5 v${iconShadeHeight-10} a 5 5 0 0 1 -5 5 h-${iconShadeWidth-5} v-${iconShadeHeight}` :
`M5 0 h${iconShadeWidth-5} v${iconShadeHeight} h-${iconShadeWidth-5} a 5 5 0 0 1 -5 -5 v-${iconShadeHeight-10} a 5 5 0 0 1 5 -5`
)
)
this.__iconShadeBorder__.style.display = hideLabel?'none':''
this.__iconShadeBorder__.setAttribute("d", this.__iconShadeBorder__.setAttribute("d",
"M " + (((!d._def.align && d.inputs !== 0 && d.outputs === 0) || "right" === d._def.align) ? 0 : 30) + " 1 l 0 " + (d.h - 2) "M " + (((!d._def.align && d.inputs !== 0 && d.outputs === 0) || "right" === d._def.align) ? 0.5 : 29.5) + " "+(d.selected?1:0.5)+" l 0 " + (d.h - (d.selected?2:1))
); );
faIcon.attr("y",(d.h+13)/2); faIcon.attr("y",(d.h+13)/2);
} }