Skip to content

Commit

Permalink
🐛 [Frontend] Annotations fix: Convert named colors to HEX (#6162)
Browse files Browse the repository at this point in the history
Forced merged on behalf of @odeimaiz
  • Loading branch information
odeimaiz authored Aug 9, 2024
1 parent b0c60f0 commit 1fa7509
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,14 @@ qx.Class.define("osparc.utils.Utils", {
return L > 0.35 ? "#FFF" : "#000";
},

namedColorToHex: function(namedColor) {
if (qx.util.ExtendedColor.isExtendedColor(namedColor)) {
const rgb = qx.util.ExtendedColor.toRgb(namedColor);
return qx.util.ColorUtil.rgbToHexString(rgb);
}
return "#888888";
},

bytesToSize: function(bytes, decimals = 2, isDecimalCollapsed = true) {
if (!+bytes) {
return "0 Bytes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ qx.Class.define("osparc.workbench.Annotation", {
if (id === undefined) {
id = osparc.utils.Utils.uuidV4();
}
let color = "color" in data ? data.color : this.getColor();
if (color && color[0] !== "#") {
color = osparc.utils.Utils.namedColorToHex(color);
}
this.set({
id,
type: data.type,
color: "color" in data ? data.color : this.getColor(),
color,
attributes: data.attributes
});
},
Expand Down

0 comments on commit 1fa7509

Please sign in to comment.