UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

44 lines 1.55 kB
import Color from "color"; /** * converts a react-flow node with * type = "stickynote" to StickyNote type compatible with the backend * @param node * @returns {StickyNote} */ var transformNodeToStickyNode = function (node) { var _a, _b, _c; return { id: node.id, content: node.data.businessData.stickyNote, position: { x: node.position.x, y: node.position.y, width: (_a = node.data.nodeDimensions) === null || _a === void 0 ? void 0 : _a.width, height: (_b = node.data.nodeDimensions) === null || _b === void 0 ? void 0 : _b.height }, color: (_c = node.data.style) === null || _c === void 0 ? void 0 : _c.borderColor, }; }; /** * takes in a hex color string and returns * a style object with style rules for borderColor, backgroundColor and color * @param {string} color * @returns {CSSProperties} */ var generateStyleWithColor = function (color) { var style = {}; try { var colorObj = Color("#fff").mix(Color(color), 0.24); style = { backgroundColor: colorObj.toString(), borderColor: color, color: colorObj.isLight() ? "#000" : "#fff", }; } catch (_a) { // eslint-disable-next-line no-console console.warn("Received invalid color for sticky note: " + color); } return style; }; export var nodeDefaultUtils = { generateStyleWithColor: generateStyleWithColor, transformNodeToStickyNode: transformNodeToStickyNode, }; export default nodeDefaultUtils; //# sourceMappingURL=nodeUtils.js.map