UNPKG

@eccenca/gui-elements

Version:

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

50 lines 1.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.nodeDefaultUtils = void 0; const color_1 = __importDefault(require("color")); /** * converts a react-flow node with * type = "stickynote" to StickyNote type compatible with the backend * @param node * @returns {StickyNote} */ const transformNodeToStickyNode = (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} */ const generateStyleWithColor = (color) => { let style = {}; try { const colorObj = (0, color_1.default)("#fff").mix((0, color_1.default)(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; }; exports.nodeDefaultUtils = { generateStyleWithColor, transformNodeToStickyNode, }; exports.default = exports.nodeDefaultUtils; //# sourceMappingURL=nodeUtils.js.map