From f5e46a663a9cfbfff18a358a9489a55daba989f0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 7 Jul 2020 11:01:05 +0100 Subject: [PATCH] Remove hardcoded css and allow group to default from theme Fixes #2633 --- .../editor-client/src/js/ui/group.js | 24 +++++++++++++++---- .../src/js/ui/touch/radialMenu.js | 10 ++++---- .../@node-red/editor-client/src/js/ui/view.js | 17 +++++++------ .../editor-client/src/sass/colors.scss | 1 + .../editor-client/src/sass/flow.scss | 6 +++++ .../editor-client/src/sass/radialMenu.scss | 6 ++++- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/group.js b/packages/node_modules/@node-red/editor-client/src/js/ui/group.js index ffce9f179..9dbd9c19b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/group.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/group.js @@ -83,7 +83,8 @@ RED.group = (function() { } var defaultGroupStyle = { - label: true + label: true, + "label-position": "nw" }; var groupDef = { @@ -97,7 +98,7 @@ RED.group = (function() { var style = this.style || {}; RED.colorPicker.create({ id:"node-input-style-stroke", - value: style.stroke || "#a4a4a4", + value: style.stroke || defaultGroupStyle.stroke || "#a4a4a4", palette: colorPalette, cellPerRow: colorCount, cellWidth: 16, @@ -125,7 +126,7 @@ RED.group = (function() { RED.colorPicker.create({ id:"node-input-style-color", - value: style.color || "#a4a4a4", + value: style.color || defaultGroupStyle.color ||"#a4a4a4", palette: colorPalette, cellPerRow: colorCount, cellWidth: 16, @@ -167,6 +168,13 @@ RED.group = (function() { if (this.style["fill-opacity"] === "1") { delete this.style["fill-opacity"] } + var node = this; + ['stroke','fill','stroke-opacity','fill-opacity','color','label-position'].forEach(function(prop) { + if (node.style[prop] === defaultGroupStyle[prop]) { + delete node.style[prop] + } + }) + this.resize = true; }, set:{ @@ -219,9 +227,17 @@ RED.group = (function() { "stroke-opacity": groupStyle.strokeOpacity, fill: convertColorToHex(groupStyle.fill), "fill-opacity": groupStyle.fillOpacity, - label: true + label: true, + "label-position": "nw" } groupStyleDiv.remove(); + groupStyleDiv = $("
",{ + class:"red-ui-flow-group-label", + style: "position: absolute; top: -1000px;" + }).appendTo(document.body); + groupStyle = getComputedStyle(groupStyleDiv[0]); + defaultGroupStyle.color = convertColorToHex(groupStyle.fill); + groupStyleDiv.remove(); } function convertColorToHex(c) { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/touch/radialMenu.js b/packages/node_modules/@node-red/editor-client/src/js/ui/touch/radialMenu.js index a7c9704d9..9ed7f823c 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/touch/radialMenu.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/touch/radialMenu.js @@ -112,14 +112,14 @@ RED.touch.radialMenu = (function() { if (!opt.disabled) { if (p[0]>opt.x-30 && p[0]opt.y-30 && p[1]